private RecognitionRequest GenerateRecognizeRequest(string content, List <string[]> contexts, Enumerators.LanguageCode language) { RecognitionRequest request = new RecognitionRequest(); request.config.encoding = _currentConfig.audioEncoding.ToString(); request.config.languageCode = language.ToString().Replace("_", "-"); request.config.sampleRateHertz = _currentConfig.sampleRate; request.config.maxAlternatives = _currentConfig.maxAlternatives; request.config.profanityFilter = _currentConfig.isEnabledProfanityFilter; if (contexts != null) { request.config.speechContexts = new SpeechContext[contexts.Count]; for (int i = 0; i < contexts.Count; i++) { request.config.speechContexts[i] = new SpeechContext(); request.config.speechContexts[i].phrases = contexts[i]; } } request.audio.content = content; return(request); }
public string PrepareLanguage(Enumerators.LanguageCode lang) { return(lang.ToString().Replace("_", "-")); }