compulim / web-speech-cognitive-services

Polyfill Web Speech API with Cognitive Services Bing Speech for both speech-to-text and text-to-speech service.
https://compulim.github.io/web-speech-cognitive-services
MIT License
60 stars 18 forks source link

Ways to add language identification (Interface Scalability) #212

Open DavidJiang9 opened 11 months ago

DavidJiang9 commented 11 months ago

I encounter a use case where we want to add multi-language speech recognizer for English and Chinese. The below code is the sample code provided by Micrsoft Azure.

var autoDetectSourceLanguageConfig = SpeechSDK.AutoDetectSourceLanguageConfig.fromLanguages(["en-US", "de-DE"]);
var speechRecognizer = SpeechSDK.SpeechRecognizer.FromConfig(speechConfig, autoDetectSourceLanguageConfig, audioConfig);
speechRecognizer.recognizeOnceAsync((result: SpeechSDK.SpeechRecognitionResult) => {
        var languageDetectionResult = SpeechSDK.AutoDetectSourceLanguageResult.fromResult(result);
        var detectedLanguage = languageDetectionResult.language;
},
{});

I didn't see a way to add the configuration like above. Is there a way to do this? Thanks. @compulim @traviscibot