Open DineshGuptaa opened 6 years ago
Hi All,
I tried to make websocket connection from a single file I used code from here https://github.com/gorilla/websocket/blob/master/examples/echo/client.go and after making a connection I sent the config but I receive the error. code is as below
textMsg := msrecognize.GetHeaders("speech.config", "547578238432049")
config, err := msrecognize.GetSpeechConfig()
textMsg = fmt.Sprintf("%s\n%s", textMsg, config)
err = c.WriteMessage(websocket.TextMessage, []byte(textMsg))
and
func GetSpeechConfig() (string,error) {
gi := goInfo.GetInfo()
device := Device{Manufacturer:"JioSample",Model:"JioSample",Version:version}
os := OS{Platform:"x86_64", Name: gi.GoOS, Version:gi.Core}
system := System{Version: version}
context := Context{System: system,OS:os, Device:device}
config := SpeechConfig{Context:context}
byt, err := json.Marshal(config)
if err == nil{
return string(byt), err
}else{
return "", err
}
}
func GetHeaders(params... string) string{
header := fmt.Sprintf("path: %s\n", params[0])
header += fmt.Sprintf("x-requestid: %s\n",params[1])//request id
header += fmt.Sprintf("x-timestamp: %s\n",GetTimestamp())// timestamp
header += fmt.Sprintf("content-type: %s\n","application/json; charset=utf-8")////content type
return header
}
And received below response from service:
connecting to wss://speech.platform.bing.com/speech/recognition/interactive/cognitiveservices/v1? format=simple&language=en-US&Ocp-Apim-Subscription-Key=e140575af9064bd8a2e5e47a0b5e829a&X- ConnectionId=9AD09FD5DD244BBCBCA2B8DC8AB91A9B
read: websocket: close 1007 (invalid payload data): Incorrect message format. Text message contains no header separator
Please help me on the same or suggest me any implementation on Golang. I am stuck here unable to proceed.
Regards, Dinesh Gupta
Hi All, Now I am able correct format so that can be accepted by speech.config
textMsg := msrecognize.GetHeaders("speech.config", "547578238432049", "application/json; charset=utf-8")
config, err := msrecognize.GetSpeechConfig()
textMsg = fmt.Sprintf("%s\n%s", textMsg, config)
-->s := strings.Replace(textMsg, "\n", "\r\n", -1)
err = c.WriteMessage(websocket.TextMessage, []byte(s))
Now I am have different issue. As I am sending the text message, same way I tried to send binary data
textMsg1 := msrecognize.GetHeaders("audio", "547578238432049", "audio/x-wav")
_, err1 := ioutil.ReadFile("C:/Users/dinesh/Desktop/Test.wav")
textMsg = fmt.Sprintf("%s\n%s", textMsg1, string("RIFF,"))
ss := strings.Replace(textMsg, "\n", "\r\n", -1)\
err1 = c.WriteMessage(websocket.BinaryMessage, []byte(ss))
I am getting below repsonse from service:
websocket: close 1007 (invalid payload data): Incorrect message format. Binary message has invalid header size
Please help me to send send the binary data to speech websocket
Regards, Dinesh Gupta
Hi,
I want to make hands-free service for the mobile user so that user can speak and that should convert into text. I am implementing using Golang. I am refering https://docs.microsoft.com/en-us/azure/cognitive-services/speech/api-reference-rest/websocketprotocol
I am creation Gorilla WebSocket connection & getting the response as:
After that I am sending the text message
After sending above message I am getting below error message
Please help me MS STT implemetion in Golang
Thanks Dinesh Gupta