/// <summary> /// Listen and perform the translation using foreign voice and language fields /// </summary> private async void Translate() { try { _assetWrapper.PlaySystemSound(SystemSound.SystemWakeWord); _assetWrapper.ShowSystemImage(SystemImage.Joy); await _misty.StartRecordingAudioAsync("TranslateAzureAudio.wav"); _misty.Wait(5000); await _misty.StopRecordingAudioAsync(); _assetWrapper.PlaySystemSound(SystemSound.SystemSuccess); _misty.Wait(500); IGetAudioResponse audioResponse = await _misty.GetAudioAsync("TranslateAzureAudio.wav", false); TranslationRecognitionResult description = await _azureCognitive.TranslateAudioStream((byte[])audioResponse.Data.Audio, _fromForeignLanguage, new List <string> { _toForeignLanguage }); if (description.Translations.Any()) { string translation = description.Translations.FirstOrDefault(x => x.Key == _toForeignLanguage).Value; //Sometimes comes back without region if (string.IsNullOrWhiteSpace(translation)) { string toLanguage2 = _toForeignLanguage.Split('-')[0]; translation = description.Translations.FirstOrDefault(x => x.Key == toLanguage2).Value; } if (string.IsNullOrWhiteSpace(translation)) { BroadcastDetails("I am unable to translate this.", _defaultVoice); } else { BroadcastDetails(translation, _foreignVoice); } } _assetWrapper.ShowSystemImage(SystemImage.ContentRight); } catch (Exception ex) { _misty.SkillLogger.Log("Failed to translate the audio input.", ex); } }