voice

command
v0.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

README

Installation

go get github.com/chenqinghe/baidu-ai-go-sdk/voice

Usage

  • 创建VoiceClient
    	var apiKey,apiSecret string 
	apiKey = "XXXXXXX"
	apiSecret = "XXXXXXX"
	client := voice.NewVoiceClient(apiKey,apiSecret)
  • 语音合成
	bts,err:=client.TextToSpeech("你好")
	if err!=nil{
		log.Fatal(err)
	}
	if err:=writeBytesToFile(bts,filename);err!=nil{//writeBytesToFile需要自己实现
		log.Fatal(err)
	}
  • 语音识别
	var ap ASRParams = ASRParams{
		Format:  "wav",
		Rate:    16000,
		Channel: 1,
		Cuid:    "mac address",
		Token:   client.AccessToken,
		Lan:     "zh",
		Speech:  afterBase64Str,
		Len:     fiLen,
	}
	strs,err:=client.SpeechToText(ap)
	if err!=nil{
		log.Fatal(err)
	}	
	fmt.Println(strs)//[]string,翻译候选结果,5个。

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL