Skip to content

Commit a62891e

Browse files
committed
java variables
1 parent 98b7ca4 commit a62891e

File tree

1 file changed

+12
-12
lines changed
  • articles/ai-services/speech-service/includes/how-to/translate-speech

1 file changed

+12
-12
lines changed

articles/ai-services/speech-service/includes/how-to/translate-speech/java.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ static void translateSpeech() throws ExecutionException, InterruptedException {
192192
try (TranslationRecognizer translationRecognizer = new TranslationRecognizer(speechTranslationConfig)) {
193193
System.out.printf("Say something in '%s' and we'll translate...", fromLanguage);
194194

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()) {
199199
System.out.printf("Translated into '%s': %s\n", pair.getKey(), pair.getValue());
200200
}
201201
}
@@ -248,10 +248,10 @@ static void translateSpeech() throws ExecutionException, FileNotFoundException,
248248

249249
System.out.printf("Say something in '%s' and we'll translate...", fromLanguage);
250250

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()) {
255255
String language = pair.getKey();
256256
String translation = pair.getValue();
257257
System.out.printf("Translated into '%s': %s\n", language, translation);
@@ -282,8 +282,8 @@ static void translateSpeech() throws ExecutionException, InterruptedException {
282282
try (TranslationRecognizer translationRecognizer = new TranslationRecognizer(speechTranslationConfig)) {
283283
System.out.printf("Say something in '%s' and we'll translate...", fromLanguage);
284284

285-
TranslationRecognitionResult result = translationRecognizer.recognizeOnceAsync().get();
286-
if (result.getReason() == ResultReason.TranslatedSpeech) {
285+
TranslationRecognitionResult translationRecognitionResult = translationRecognizer.recognizeOnceAsync().get();
286+
if (translationRecognitionResult.getReason() == ResultReason.TranslatedSpeech) {
287287
// See: https://aka.ms/speech/sdkregion#standard-and-neural-voices
288288
Map<String, String> languageToVoiceMap = new HashMap<String, String>();
289289
languageToVoiceMap.put("de", "de-DE-KatjaNeural");
@@ -292,8 +292,8 @@ static void translateSpeech() throws ExecutionException, InterruptedException {
292292
languageToVoiceMap.put("pt", "pt-BR-FranciscaNeural");
293293
languageToVoiceMap.put("zh-Hans", "zh-CN-XiaoxiaoNeural");
294294

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()) {
297297
String language = pair.getKey();
298298
String translation = pair.getValue();
299299
System.out.printf("Translated into '%s': %s\n", language, translation);

0 commit comments

Comments
 (0)