Change Azure Speech Recognition Language

Francisco Ramos 21 Reputation points
2022-04-26T18:43:21.473+00:00

Hi,

Is it possible to change the SpeechRecognizer's language at runtime after the recognizer has been created. If for example I start the recognition with English specified and I want it changed to Spanish? I saw that the recognizer has a "SpeechRecognitionLanguage" property but it's readonly.

If not possible, would the correct way to approach be to tear down the first recognizer, create a second recognizer with the new language and switch to it?

Thanks.

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,413 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 46,991 Reputation points
    2022-04-26T23:25:07.697+00:00

    Hello @Francisco Ramos

    Thanks for reching out to us. I think you are mentioning how to set the recognizer's source lanague in Speech SDK. When you created a recoginizer, I don't think you can change it. But you can easily create a new one. The langage config we are using is "source_language_config" for Python.

    You need to set the language as below - Python:

    source_language_config = speechsdk.languageconfig.SourceLanguageConfig("de-DE")  
    speech_recognizer = speechsdk.SpeechRecognizer(  
            speech_config=speech_config, source_language_config=source_language_config, audio_config=audio_config)  
    

    C#:

    var sourceLanguageConfig = SourceLanguageConfig.FromLanguage("de-DE");  
    var recognizer = new SpeechRecognizer(speechConfig, sourceLanguageConfig, audioConfig);  
    

    JAVA:

    SourceLanguageConfig sourceLanguageConfig = SourceLanguageConfig.fromLanguage("de-DE");  
    SpeechRecognizer recognizer = new SpeechRecognizer(speechConfig, sourceLanguageConfig, audioConfig);  
    

    I hope this helps.

    Please let me know if you need further help, we are glad to help.

    Regards,
    Yutong

    -Please kindly accept the answer if you feel helpful, thanks.