Text2Speech in Golang sdk provided in IBM Watson.

Tuned Gopher.
package mainimport ("bytes"
"fmt"
"os"
"github.com/IBM/go-sdk-core/core"
"github.com/watson-developer-cloud/go-sdk/texttospeechv1"
)func main() {authenticator := &core.IamAuthenticator{ApiKey: "tF#######################ZD@@",}options := &texttospeechv1.TextToSpeechV1Options{Authenticator: authenticator,}textToSpeech,textToSpeechErr:= texttospeechv1.NewTextToSpeechV1(options)
if textToSpeechErr != nil {
panic(textToSpeechErr)
}
textToSpeech.SetServiceURL("https://api.eu-gb.text-to-speech.watson.cloud.ibm.com##############")result, response, responseErr := textToSpeech.Synthesize(&texttospeechv1.SynthesizeOptions{Text: core.StringPtr("Welcome to the world of Go"),
Accept: core.StringPtr("audio/wav"),
Voice: core.StringPtr(texttospeechv1.SynthesizeOptionsVoiceEnGbJamesv3voiceConst),
},
)
fmt.Println(response)
if responseErr != nil {
panic(responseErr)
}
if result != nil {
buff := new(bytes.Buffer)
buff.ReadFrom(result)
file, _ := os.Create("hello_world.wav")
file.Write(buff.Bytes())
file.Close()
}
}
  1. Text: (“Welcome to the world of Go”),
  2. Accept: (“audio/wav”)
  3. Voice: (texttospeechv1.SynthesizeOptionsVoiceEnGbJamesv3voiceConst)

--

--

--

A Gopher in the world of Go

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CS373 Fall 2021 week 4blog: Kang (Kevin) Hou

Why NODE.JS for Business App Development in 2021?

Four Surprising Reasons You Need an All-Star QA Team

How to Build Android App -Step by Step Guide — Eskill Training

Model Driven App: How to dynamically create a HTML table from the sub grid in the Email Template

Upgrade AWS EKS Cluster with Zero Downtime

Handling iOS 13 Bluetooth Permissions

Under The Bonnet: Floating Point

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Iamkochukulam

Iamkochukulam

A Gopher in the world of Go

More from Medium

Null Pointer Challenge in Golang

Time Format in Go-lang

Detect & Find Faces and Landmarks (Eyes, Nose & Mouth) in an Image using Go