https://github.com/chekun/baidu-yuyin
百度语音识别SDK for Go
https://github.com/chekun/baidu-yuyin
baidu-yuyin-sdk baiduyuyin
Last synced: about 1 year ago
JSON representation
百度语音识别SDK for Go
- Host: GitHub
- URL: https://github.com/chekun/baidu-yuyin
- Owner: chekun
- License: mit
- Created: 2017-06-06T00:50:01.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-06T05:59:34.000Z (about 9 years ago)
- Last Synced: 2024-10-19T01:13:34.336Z (over 1 year ago)
- Topics: baidu-yuyin-sdk, baiduyuyin
- Language: Go
- Size: 3.91 KB
- Stars: 9
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
百度语音识别SDK for Go
===============================
第一个可用版本,随心使用,注意安全 😄
## 安装
```
go get -u github.com/chekun/baidu-yuyin
```
## 使用方法:
```go
import (
"fmt"
"os"
"github.com/chekun/baidu-yuyin/asr"
"github.com/chekun/baidu-yuyin/oauth"
)
clientID := "your-client-id"
clientSecret := "your-client-secret"
auth := oauth.New(clientID, clientSecret, oauth.NewMemoryCacheMan())
//一次性使用也可以不缓存token, 如下
//auth := oauth.New(clientID, clientSecret, nil)
//也可以实现自己的缓存,往下看⬇️ ️ ️
token, err := auth.GetToken()
if err != nil {
panic(err)
}
file, err := os.Open("speech.wav")
if err != nil {
panic(err)
}
defer file.Close()
fmt.Println(asr.ToText(token, file))
```
你也可以用实现自己的`token缓存`, 实现这个`oauth.CacheMan`接口即可
```go
type CacheMan interface {
Get() (string, error)
Set(string, int) error
IsValid() bool
}
```
最后在 `oauth.New` 的时候传入。