@@ -192,10 +192,10 @@ static void translateSpeech() throws ExecutionException, InterruptedException {
192
192
try (TranslationRecognizer translationRecognizer = new TranslationRecognizer (speechTranslationConfig)) {
193
193
System . out. printf(" Say something in '%s' and we'll translate..." , fromLanguage);
194
194
195
- TranslationRecognitionResult result = translationRecognizer. recognizeOnceAsync(). get();
196
- if (result . getReason() == ResultReason . TranslatedSpeech ) {
197
- System . out. printf(" Recognized: \" %s\"\n " , result . getText());
198
- for (Map . Entry<String , String > pair : result . getTranslations(). entrySet()) {
195
+ TranslationRecognitionResult translationRecognitionResult = translationRecognizer. recognizeOnceAsync(). get();
196
+ if (translationRecognitionResult . getReason() == ResultReason . TranslatedSpeech ) {
197
+ System . out. printf(" Recognized: \" %s\"\n " , translationRecognitionResult . getText());
198
+ for (Map . Entry<String , String > pair : translationRecognitionResult . getTranslations(). entrySet()) {
199
199
System . out. printf(" Translated into '%s': %s\n " , pair. getKey(), pair. getValue());
200
200
}
201
201
}
@@ -248,10 +248,10 @@ static void translateSpeech() throws ExecutionException, FileNotFoundException,
248
248
249
249
System . out. printf(" Say something in '%s' and we'll translate..." , fromLanguage);
250
250
251
- TranslationRecognitionResult result = translationRecognizer. recognizeOnceAsync(). get();
252
- if (result . getReason() == ResultReason . TranslatedSpeech ) {
253
- System . out. printf(" Recognized: \" %s\"\n " , result . getText());
254
- for (Map . Entry<String , String > pair : result . getTranslations(). entrySet()) {
251
+ TranslationRecognitionResult translationRecognitionResult = translationRecognizer. recognizeOnceAsync(). get();
252
+ if (translationRecognitionResult . getReason() == ResultReason . TranslatedSpeech ) {
253
+ System . out. printf(" Recognized: \" %s\"\n " , translationRecognitionResult . getText());
254
+ for (Map . Entry<String , String > pair : translationRecognitionResult . getTranslations(). entrySet()) {
255
255
String language = pair. getKey();
256
256
String translation = pair. getValue();
257
257
System . out. printf(" Translated into '%s': %s\n " , language, translation);
@@ -282,8 +282,8 @@ static void translateSpeech() throws ExecutionException, InterruptedException {
282
282
try (TranslationRecognizer translationRecognizer = new TranslationRecognizer (speechTranslationConfig)) {
283
283
System . out. printf(" Say something in '%s' and we'll translate..." , fromLanguage);
284
284
285
- TranslationRecognitionResult result = translationRecognizer. recognizeOnceAsync(). get();
286
- if (result . getReason() == ResultReason . TranslatedSpeech ) {
285
+ TranslationRecognitionResult translationRecognitionResult = translationRecognizer. recognizeOnceAsync(). get();
286
+ if (translationRecognitionResult . getReason() == ResultReason . TranslatedSpeech ) {
287
287
// See: https://aka.ms/speech/sdkregion#standard-and-neural-voices
288
288
Map<String , String > languageToVoiceMap = new HashMap<String , String > ();
289
289
languageToVoiceMap. put(" de" , " de-DE-KatjaNeural" );
@@ -292,8 +292,8 @@ static void translateSpeech() throws ExecutionException, InterruptedException {
292
292
languageToVoiceMap. put(" pt" , " pt-BR-FranciscaNeural" );
293
293
languageToVoiceMap. put(" zh-Hans" , " zh-CN-XiaoxiaoNeural" );
294
294
295
- System . out. printf(" Recognized: \" %s\"\n " , result . getText());
296
- for (Map . Entry<String , String > pair : result . getTranslations(). entrySet()) {
295
+ System . out. printf(" Recognized: \" %s\"\n " , translationRecognitionResult . getText());
296
+ for (Map . Entry<String , String > pair : translationRecognitionResult . getTranslations(). entrySet()) {
297
297
String language = pair. getKey();
298
298
String translation = pair. getValue();
299
299
System . out. printf(" Translated into '%s': %s\n " , language, translation);
0 commit comments