public static async Task TestTranslatorTextApiKeyAsync(string key) { if (string.IsNullOrEmpty(key)) { throw new ArgumentException("Invalid API Key"); } string testQuery = "Hello world"; var service = new TranslatorTextService(key); var result = await service.DetectLanguageAsync(testQuery); }
public TranslatorSpeechMiddleware(string translatorSpeechKey, string translatorKey, string voiceFontName, string voiceFontLanguage) { if (string.IsNullOrEmpty(translatorSpeechKey)) { throw new ArgumentNullException(nameof(translatorSpeechKey)); } if (string.IsNullOrEmpty(translatorKey)) { throw new ArgumentNullException(nameof(translatorKey)); } this._translatorTextService = new TranslatorTextService(translatorKey); this._translatorSpeechService = new TranslatorSpeechService(translatorSpeechKey); this._textToSpeechService = new TextToSpeechService(); }
public TranslatorSpeechMiddleware(string speechKey, string translatorKey, string region, IStatePropertyAccessor <ReservationData> reservationStateAccessor) { ReservationStateAccessor = reservationStateAccessor ?? throw new ArgumentNullException(nameof(reservationStateAccessor)); if (string.IsNullOrEmpty(speechKey)) { throw new ArgumentNullException(nameof(speechKey)); } if (string.IsNullOrEmpty(translatorKey)) { throw new ArgumentNullException(nameof(translatorKey)); } this._translatorTextService = new TranslatorTextService(translatorKey); this._speechTranslationService = new SpeechTranslationService(speechKey, region); this._textToSpeechService = new TextToSpeechService(); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { if (string.IsNullOrEmpty(SettingsHelper.Instance.TranslatorTextApiKey)) { await new MessageDialog("Missing Translator Text API Key. Please enter the key in the Settings page.", "Missing API Key").ShowAsync(); } else { this.translatorTextService = new TranslatorTextService(SettingsHelper.Instance.TranslatorTextApiKey, SettingsHelper.Instance.TranslatorTextApiRegion); await LoadSupportedLanguagesAsync(); LoadSamplePhrases(); timer.Start(); } base.OnNavigatedTo(e); }