hiexam
microsoft · AI-102 · Q269 · code_completion · speech_translation, language_recognition, azure_sdk

Fill in the code snippet to correctly configure the translation languages and initialize the TranslationRecognizer.

Fill in the code snippet to correctly configure the translation languages and initialize the TranslationRecognizer.
static async Task TranslateSpeechAsync() {
  var config = SpeechTranslationConfig.FromSubscription("{{slot1}}", "{{slot2}}", "{{slot3}}");
  var lang = new List<string> { {{slot4}} };
  config.SpeechRecognitionLanguage = "{{slot5}}";
  lang.ForEach(config.AddTargetLanguage);

  using var audioConfig = AudioConfig.FromDefaultMicrophoneInput();
  using var recognizer = new TranslationRecognizer(config, audioConfig);

  var result = await recognizer.RecognizeOnceAsync();
  if (result.Reason == ResultReason.TranslatedSpeech)
    Console.WriteLine(result.Translations["{{slot6}}"]);
}
Correct slot values

Answer hidden

Unlock AI-102

First 5 questions of every exam are free. Unlock the rest.

Includes
  • · All — questions
  • · Verified answers + AI explanations
  • · Spaced-repetition mistake notebook
  • · Phone, tablet, laptop sync

One-time payment. Doesn't auto-renew. · Already paid? Sign in