Open minimaximus opened 10 months ago
Can you try to record the audio, I know some time back there was a issue with the decoder or something that a returned a pattern in audio data instead of silence, this still could also be here the case, maybe you can try to record the audio data to a file and listen if there is some noise instead of the expected silence, then check for the pattern and replace the package with a real empty package (the audio packages also have a flag indicating if the audio package is silence)
So I'm trying to create a STT solution that's part of a Teams Bot. The Bot takes part of the meeting and listens to participants' audio. The audio is set to Unmixed = true so that each speaker gets their own channel. The solution is in C#. I tried this with EchoBot and PsiBot, with similar results. I upgraded both solutions to the latest Graph and Skype.Media and .NET SDKs.
I receive the separate audio buffers in real-time, and I send them to a Cognitive Services class to recognize the speech. Every participant gets their own Cognitive Services recognizer class instance.
My problem is that the messages get to the recognizer, and you can see the recognizing event fire consistently. However, the final recognized event only fires sporadically, even with long periods of silence. I'm not sure where the issue is. Any help is greatly appreciated.
Here's where the audio is sent to langServices:
if (audioFrame.UnmixedAudioBuffers != null) { var tasks = new List(); foreach (var buffer in audioFrame.UnmixedAudioBuffers) { var length = buffer.Length; var data = new byte[length]; Marshal.Copy(buffer.Data, data, 0, (int)length);
} await Task.WhenAll(tasks); }
Here are the relevant snippets from CognitiveServices class:
public CognitiveServicesService(Identity identity, BotConfiguration settings, IGraphLogger logger, string callId) { _logger = logger; _callId = callId; _identity = identity;
_speechConfig = SpeechConfig.FromSubscription(settings.SpeechConfigKey, settings.SpeechConfigRegion); _speechConfig.SpeechSynthesisLanguage = settings.BotLanguage; _speechConfig.SpeechRecognitionLanguage = settings.BotLanguage;
//_speechConfig.SetProperty(PropertyId.Speech_SegmentationSilenceTimeoutMs, "1000"); //_speechConfig.SetProperty(PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, "1000");
var audioConfig = AudioConfig.FromStreamOutput(_audioOutputStream); }
public async Task AppendAudioBuffer(byte[] audioBuffer) { //RealtimeTranscriptionHelper.TranscribeAsync(audioBuffer, _speechConfig, _logger); if (!_isRunning) { Start(); await ProcessSpeech(); }
try { _audioInputStream.Write(audioBuffer); } catch (Exception e) { _logger.Log(System.Diagnostics.TraceLevel.Info, e, "Exception happend writing to input stream"); } }
private async Task ProcessSpeech() { try {
} catch (ObjectDisposedException ex) { _logger.Log(System.Diagnostics.TraceLevel.Error, ex, "The queue processing task object has been disposed."); } catch (Exception ex) { // Catch all other exceptions and log _logger.Log(System.Diagnostics.TraceLevel.Error, ex, "Caught Exception"); } }
The expected behavior is that the Recognized event will fire after a brief period of silence by the speaker in that channel, but in reality, the Recognizing event keeps firing until some seemingly random time. This behavior is not observed when UnmixedAudio is set to false, but it's not the desired set up.