I am trying to send an audio file (.wav) for speech-to-text using ibm-watson service and websocket-sharp.I'm doing it in an asp.net mvc action by using a sample .wav file of 80kb. While following this tutorial speech-to-text/websockets.
I'm doing the following
var ws = new WebSocket("wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize?watson-token=" + token);
ws.OnOpen += ws_OnOpen;
ws.OnMessage += ws_OnMessage;
ws.OnClose += ws_OnClose;
ws.OnError += ws_OnError;
ws.Connect();
string startActionjson = "{'action': 'start', 'content-type': 'audio/wav', 'continuous' : true, 'interim_results': true, 'inactivity_timeout': -1,}";
ws.SendAsync(startActionjson, b =>
{
if (b == true)
{
//send the audio as binary
string filePath = "E:\\Test Folders\\Sample\\test003.wav";
byte[] bytes = System.IO.File.ReadAllBytes(filePath);
ws.SendAsync(bytes, b1 =>
{
if(b1)
ws.Close();
});
}
});
After the start action is sent, my websocket's readystate remains Open but as soon as the line for sending the bytes executes, i receive the following in my OnMessage event
{
"name": "error",
"error": "Expecting property name: line 1 column 2 (char 1)"
}
and readystate updates itself as 'Closed'.
I have tried sending the FileStream as well, its doing so on both chrome and firefox. Any help or direction to solution will be highly appreciable.
Thanks