{"action":"created","issue":{"url":"https://api.github.com/repos/esphen/wsta/issues/5","repository_url":"https://api.github.com/repos/esphen/wsta","labels_url":"https://api.github.com/repos/esphen/wsta/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/esphen/wsta/issues/5/comments","events_url":"https://api.github.com/repos/esphen/wsta/issues/5/events","html_url":"https://github.com/esphen/wsta/issues/5","id":157049686,"number":5,"title":"Issue sending JSON and then audio Watson Speech to Text service","user":{"login":"nfriedly","id":114976,"avatar_url":"https://avatars.githubusercontent.com/u/114976?v=3","gravatar_id":"","url":"https://api.github.com/users/nfriedly","html_url":"https://github.com/nfriedly","followers_url":"https://api.github.com/users/nfriedly/followers","following_url":"https://api.github.com/users/nfriedly/following{/other_user}","gists_url":"https://api.github.com/users/nfriedly/gists{/gist_id}","starred_url":"https://api.github.com/users/nfriedly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfriedly/subscriptions","organizations_url":"https://api.github.com/users/nfriedly/orgs","repos_url":"https://api.github.com/users/nfriedly/repos","events_url":"https://api.github.com/users/nfriedly/events{/privacy}","received_events_url":"https://api.github.com/users/nfriedly/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-05-26T18:35:35Z","updated_at":"2016-06-02T22:19:59Z","closed_at":null,"body":"Hey, this is a followup to the comments I left on hacker news. I'm trying to send an opening JSON message and then audio data to the Watson STT service. It was suggested that something like this would work:\r\n\r\n    arecord -fdat | cat start.json - | wsta 'wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize?watson-token=...\r\n\r\n(Getting a token requires some fiddling around with bluemix for credentials and converting it to a token via either curl or your favorite SDK... or just go to [the demo](https://speech-to-text-demo.mybluemix.net/), open the dev console, and grab one - they're reusable for a short period of time. OR, if wsta supports custom headers, you can stick the credentials into a basic auth header and skip the token.)\r\n\r\nAnd, start.json looks like this:\r\n\r\n    {\"action\":\"start\",\"content-type\":\"audio/wav\",\"interim_results\":\"true\"}\r\n\r\nHowever, when I do that, I get a ton of `error: stream did not contain valid UTF-8` messages, and then the normal `{\"state\": \"listening\"}` message that acknowledges my initial JSON, and then a `\"No JSON object could be decoded\"` error. \r\n\r\nMy best guess is that wsta is correctly marking the opening JSON as a UTF-8 message, and then incorrectly marking all of the audio data as UTF-8 messages also.  Does this sound likely? Is that reasonably easy to fix?\r\n\r\nFWIW, the service also expects a closing JSON message at the end.. but that's not nearly as important because it will automatically kill the connection after 30 seconds of silence."},"comment":{"url":"https://api.github.com/repos/esphen/wsta/issues/comments/223439876","html_url":"https://github.com/esphen/wsta/issues/5#issuecomment-223439876","issue_url":"https://api.github.com/repos/esphen/wsta/issues/5","id":223439876,"user":{"login":"esphen","id":5845924,"avatar_url":"https://avatars.githubusercontent.com/u/5845924?v=3","gravatar_id":"","url":"https://api.github.com/users/esphen","html_url":"https://github.com/esphen","followers_url":"https://api.github.com/users/esphen/followers","following_url":"https://api.github.com/users/esphen/following{/other_user}","gists_url":"https://api.github.com/users/esphen/gists{/gist_id}","starred_url":"https://api.github.com/users/esphen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/esphen/subscriptions","organizations_url":"https://api.github.com/users/esphen/orgs","repos_url":"https://api.github.com/users/esphen/repos","events_url":"https://api.github.com/users/esphen/events{/privacy}","received_events_url":"https://api.github.com/users/esphen/received_events","type":"User","site_admin":false},"created_at":"2016-06-02T22:19:59Z","updated_at":"2016-06-02T22:19:59Z","body":"I messed around a bit more with the binary feature, and now I have something I can show. `wsta` can now stream binary data just fine.\r\n\r\nI did not succeed in getting the watson service to respond, however. Are you pre-processing the audio in any way before it is sent over the wire?\r\n\r\nIf you want to try it, you can have a look at the `binary-data` branch and run the following example. These options are not documented yet, but `-b, --binary` is a switch which turns `wsta` into binary mode where it sends at most 256 bytes at a time. You can override that size with `WSTA_BINARY_FRAME_SIZE`.\r\n\r\n```bash\r\n env WSTA_BINARY_FRAME_SIZE=16384 cargo run -- --binary 'wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize?watson-token=...' \"$(cat start.json)\" < audio-file.wav\r\n```"}}
{"actor":{"display_login":"esphen"}}