Trying to create a code in blazor application for continuous speech to text using azure cognitive services. I am trying to use Stream of input instead of voice from Microphone. Any suggestion would be helpful.
var audioFormat = AudioStreamFormat.GetWaveFormatPCM(16000, 16, 1);
var audioConfig = AudioConfig.FromStreamInput(audioStream, audioFormat);
This audio stream how to pass it from client to server?
As mentioned in the given below Microsoft documentation link, Audio can be streamed into the recognizer using the Speech SDK.
Firstly, recognize the audio input stream format which must be supported in Azure cognitive services. Then, verify that your code meets with these requirements by providing the RAW audio
. Once done, then Adapt PullAudioInputStreamCallback to create your own audio input stream class. Depending on your audio format and input stream, create an audio configuration. When you construct your recognizer, provide both the audio input setup and your normal speech configuration to the recognizer
.
Example code: -
#
var audioConfig = AudioConfig.FromStreamInput(new
ContosoAudioStream(config), audioFormat);
var speechConfig = SpeechConfig.FromSubscription(...);
var recognizer = new SpeechRecognizer(speechConfig, audioConfig);
var result = await recognizer.RecognizeOnceAsync();// Run stream through recognizer.
var text = result.GetText();