NateRickard / Xamarin.Cognitive.Speech

A client library that makes it easy to work with the Microsoft Cognitive Services Speech Services Speech to Text API on Xamarin.iOS, Xamarin.Android, UWP, and Xamarin.Forms/.NET Standard libraries used by those platforms
MIT License
59 stars 18 forks source link

Concurrent streaming while recording not working as expected #17

Closed laxnarasi closed 5 years ago

laxnarasi commented 5 years ago

We are trying to implement an SDK in Xamarin to support IoS / Android / UWP consumers , where in we wanted to stream the audio while recording from microphone to CRIS to get the speech to text transalation while talking and return the response to the consumer so that he can display it on the screen progresively. We read the documentation of the Audio Recorder plugin for Xamarin and found that it supports concurrent streaming as per the documentation (It's also possible to get a stream to the recording audio data as it's being recorded). We also referred to the Bing Speech implementation provided in the documentation.

However, we are not able to achieve this functionality. Our observation was that when StartRecording is invoked, a wav file is being written to the GetAudioFilePath () - audiofilepath (ARS_recording.wav) and it always 0 bytes while being on a recording mode (via microphone). Only when StopRecording is invoked the stream writer internally flushes the bytes to the Wav file. Hence the below code recorder.GetAudioFileStream() does not streams any data during recording due to the fact that file ARS_recording.wav is always 0 bytes while recording.

// start recording audio var audioRecordTask = await recorder.StartRecording ();

using (var stream = recorder.GetAudioFileStream ()) { // this will begin sending the recording audio data as it continues to record var simpleResult = await bingSpeechClient.SpeechToTextSimple (stream, recorder.AudioStreamDetails.SampleRate, audioRecordTask); }

Please let us know if we are in the right path and the plugin will help us in solving the above mentioned usecase.

Thanks, Lakshmi Narasimhan V

laxnarasi commented 5 years ago

Created the same issue for Plugin.AudioRecorder #32 and hence closing this request....