Azure-Samples / cognitive-services-speech-sdk

Sample code for the Microsoft Cognitive Services Speech SDK
MIT License
2.71k stars 1.81k forks source link

Automatic language detection #2361

Closed belaoud001 closed 2 months ago

belaoud001 commented 2 months ago

Hey there!

I’m trying to set up automatic language detection with the FromOpenRange() function because I’d prefer not to list every language manually with the FromLanguages() method. However, I keep running into this snag where it throws an error at me, insisting that I should use FromLanguages() instead.

I have a feeling I’m missing a crucial piece of the puzzle here, which is why I’m turning to you for some guidance. Any insights would be greatly appreciated.

Thanks a bunch!

` var speechConfig = ConfigureSpeechRecognition(); var autoDetectSourceLanguageConfig = AutoDetectSourceLanguageConfig.FromOpenRange(); var audioInputStream = CreateAudioInputStream(stream); var stopRecognition = new TaskCompletionSource();

using (var audioConfig = AudioConfig.FromStreamInput(audioInputStream)) { using (var speechRecognizer = new SpeechRecognizer(speechConfig, autoDetectSourceLanguageConfig, audioConfig)) `

pankopon commented 2 months ago

Hi, FromOpenRange() cannot be used with SpeechRecognizer (and there is no plan add support). Please see API documentation:

Only SpeechSynthesizer and embedded speech translation can detect the source language automatically.