gowebsocketgoogle-speech-apidialplanasterisk-ari

Google-speech-api throws EOF error instead of performing audio transcription


In my project I am developing a websocket server in golang which is controlling asterisk channel via ARI and performing live audio transcription on the same channel with google-speech-api. On connection I want to save audio from an asterisk channel to file while simultanously sending audio to google and get a transcript. Audio is being sent by asterisk audiofork app so that I can manipulate channel with ARI while audio is streamed on another thread.

The problem is that when I send frames to google I get EOF error on the first and every consecutive frame I send from my server but when I convert binary file with saved frames to wav using sox I get recording of audio on the channel so the frames send by audiofork aren't corrupted. Can anyone give me any advice how to make google-speech-api cooperate with me?


Solution

  • This is pretty embarrasing but this was just dumb mistake on my side because in my function creating google client I put closing client on defer so when my function retuned speech client variable it was automatically closed by the same function so after fixing that everything works as intented.