You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/Speech-Service/get-started-speech-translation.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Speech translation quickstart - Speech service
3
3
titleSuffix: Azure Cognitive Services
4
-
description: Learn how to use the Speech SDK to translate speech. In this quickstart, you learn about object construction, supported audio input formats, and configuration options for speech translation.
4
+
description: Learn how to use the Speech SDK to translate speech, including object construction, supported audio input formats, and configuration options.
Copy file name to clipboardExpand all lines: articles/cognitive-services/Speech-Service/includes/how-to/speech-translation-basics/speech-translation-basics-cli.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,17 @@ ms.date: 04/13/2020
6
6
ms.author: eric-urban
7
7
---
8
8
9
-
One of the core features of the Speech service is the ability to recognize human speech and translate it to other languages. In this quickstart you learn how to use the Speech SDK in your apps and products to perform high-quality speech translation. This quickstart translates speech from the microphone into text in another language.
9
+
One of the core features of the Speech service is the ability to recognize human speech and translate it to other languages. In this quickstart, you learn how to use the Speech SDK in your apps and products to perform high-quality speech translation. This quickstart translates speech from the microphone to text in another language.
10
10
11
11
## Prerequisites
12
12
13
-
This article assumes that you have an Azure account and Speech service subscription. If you don't have an account and subscription, [try the Speech service for free](../../../overview.md#try-the-speech-service-for-free).
13
+
This article assumes that you have an Azure account and a Speech service subscription. If you don't have an account and a subscription, [try the Speech service for free](../../../overview.md#try-the-speech-service-for-free).
14
14
15
15
[!INCLUDE [SPX Setup](../../spx-setup.md)]
16
16
17
-
## Set source and target language
17
+
## Set source and target languages
18
18
19
-
This command calls Speech CLI to translate speech from the microphone from Italian to French.
19
+
This command calls the Speech CLI to translate speech from the microphone from Italian to French:
Copy file name to clipboardExpand all lines: articles/cognitive-services/Speech-Service/includes/how-to/speech-translation-basics/speech-translation-basics-cpp.md
Copy file name to clipboardExpand all lines: articles/cognitive-services/Speech-Service/includes/how-to/speech-translation-basics/speech-translation-basics-csharp.md
Copy file name to clipboardExpand all lines: articles/cognitive-services/Speech-Service/includes/how-to/speech-translation-basics/speech-translation-basics-java.md
+33-27Lines changed: 33 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,9 @@ ms.custom: devx-track-java
7
7
ms.author: eur
8
8
---
9
9
10
-
One of the core features of the Speech service is the ability to recognize human speech and translate it to other languages. In this quickstart you learn how to use the Speech SDK in your apps and products to perform high-quality speech translation. This quickstart covers topics including:
10
+
One of the core features of the Speech service is the ability to recognize human speech and translate it to other languages. In this quickstart, you learn how to use the Speech SDK in your apps and products to perform high-quality speech translation. This quickstart covers these topics:
11
11
12
-
* Translating speech-to-text
12
+
* Translating speech to text
13
13
* Translating speech to multiple target languages
14
14
* Performing direct speech-to-speech translation
15
15
@@ -19,15 +19,15 @@ If you want to skip straight to sample code, see the [Java quickstart samples](h
19
19
20
20
## Prerequisites
21
21
22
-
This article assumes that you have an Azure account and Speech service subscription. If you don't have an account and subscription, [try the Speech service for free](../../../overview.md#try-the-speech-service-for-free).
22
+
This article assumes that you have an Azure account and a Speech service subscription. If you don't have an account and a subscription, [try the Speech service for free](../../../overview.md#try-the-speech-service-for-free).
23
23
24
-
## Install the Speech SDK
24
+
###Install the Speech SDK
25
25
26
-
Before you can do anything, you'll need to install the Speech SDK. Depending on your platform, follow the instructions under the <ahref="/azure/cognitive-services/speech-service/speech-sdk#get-the-speech-sdk"target="_blank">Get the Speech SDK </a> section of the _About the Speech SDK_ article.
26
+
Before you can do anything, you need to install the Speech SDK. Depending on your platform, follow the instructions in the <ahref="/azure/cognitive-services/speech-service/speech-sdk#get-the-speech-sdk"target="_blank">Get the Speech SDK </a> section of the _About the Speech SDK_ article.
27
27
28
-
## Import dependencies
28
+
###Import dependencies
29
29
30
-
To run the examples in this article, include the following `import` statements at the top of the **.Java* code file.
30
+
To run the examples in this article, include the following `import` statements at the top of the **.Java* code file:
The example source code in this article depends on environment variables for storing sensitive data, such as the Speech resource subscription key and region. The Java code file contains two `static final String` values that are assigned from the host machines environment variables, namely `SPEECH__SUBSCRIPTION__KEY` and `SPEECH__SERVICE__REGION`. Both of these fields are at the class scope, making them accessible within method bodies of the class. For more information on environment variables, see [environment variables and application configuration](../../../../cognitive-services-security.md#environment-variables-and-application-configuration).
45
+
The example source code in this article depends on environment variables for storing sensitive data, such as the Speech resource's subscription key and region. The Java code file contains two `static final String` values that are assigned from the host machine's environment variables: `SPEECH__SUBSCRIPTION__KEY` and `SPEECH__SERVICE__REGION`. Both of these fields are at the class scope, so they're accessible within method bodies of the class:
46
46
47
47
```java
48
48
publicclassApp {
@@ -54,21 +54,23 @@ public class App {
54
54
}
55
55
```
56
56
57
+
For more information on environment variables, see [Environment variables and application configuration](../../../../cognitive-services-security.md#environment-variables-and-application-configuration).
58
+
57
59
## Create a speech translation configuration
58
60
59
-
To call the Speech service using the Speech SDK, you need to create a [`SpeechTranslationConfig`][config]. This class includes information about your subscription, like your key and associated region, endpoint, host, or authorization token.
61
+
To call the Speech service by using the Speech SDK, you need to create a [`SpeechTranslationConfig`][config] instance. This class includes information about your subscription, like your key and associated region, endpoint, host, or authorization token.
60
62
61
63
> [!TIP]
62
64
> Regardless of whether you're performing speech recognition, speech synthesis, translation, or intent recognition, you'll always create a configuration.
63
65
64
-
There are a few ways that you can initialize a [`SpeechTranslationConfig`][config]:
66
+
You can initialize a `SpeechTranslationConfig` instance in a few ways:
65
67
66
68
* With a subscription: pass in a key and the associated region.
67
69
* With an endpoint: pass in a Speech service endpoint. A key or authorization token is optional.
68
70
* With a host: pass in a host address. A key or authorization token is optional.
69
71
* With an authorization token: pass in an authorization token and the associated region.
70
72
71
-
Let's take a look at how a [`SpeechTranslationConfig`][config] is created using a key and region. Get these credentials by following steps in [Try the Speech service for free](../../../overview.md#try-the-speech-service-for-free).
73
+
Let's look at how you create a `SpeechTranslationConfig` instance by using a key and region. Get these credentials by following the steps in [Try the Speech service for free](../../../overview.md#try-the-speech-service-for-free).
72
74
73
75
```java
74
76
publicclassApp {
@@ -93,9 +95,9 @@ public class App {
93
95
}
94
96
```
95
97
96
-
## Change source language
98
+
## Change the source language
97
99
98
-
One common task of speech translation is specifying the input (or source) language. Let's take a look at how you would change the input language to Italian. In your code, interact with the [`SpeechTranslationConfig`][config] instance, calling the `setSpeechRecognitionLanguage` method.
100
+
One common task of speech translation is specifying the input (or source) language. The following example shows how you would change the input language to Italian. In your code, interact with the `SpeechTranslationConfig` instance by calling the `setSpeechRecognitionLanguage` method:
The [`setSpeechRecognitionLanguage`][recognitionlang] function expects a language-locale format string. You can provide any value in the **Locale** column in the list of supported [locales/languages](../../../language-support.md).
112
+
The [`setSpeechRecognitionLanguage`][recognitionlang] function expects a language-locale format string. You can provide any value in the **Locale** column in the [list of supported locales/languages](../../../language-support.md).
111
113
112
-
## Add translation language
114
+
## Add a translation language
113
115
114
-
Another common task of speech translation is to specify target translation languages, at least one is required but multiples are supported. The following code snippet sets both French and German as translation language targets.
116
+
Another common task of speech translation is to specify target translation languages. At least one is required, but multiples are supported. The following code snippet sets both French and German as translation language targets:
// Translate to languages. See, https://aka.ms/speech/sttt-languages
125
+
// Translate to languages. See https://aka.ms/speech/sttt-languages
124
126
translationConfig.addTargetLanguage("fr");
125
127
translationConfig.addTargetLanguage("de");
126
128
}
@@ -130,9 +132,9 @@ With every call to [`addTargetLanguage`][addlang], a new target translation lang
130
132
131
133
## Initialize a translation recognizer
132
134
133
-
After you've created a [`SpeechTranslationConfig`][config], the next step is to initialize a [`TranslationRecognizer`][recognizer]. When you initialize a [`TranslationRecognizer`][recognizer], you'll need to pass it your `translationConfig`. The configuration object provides the credentials that the speech service requires to validate your request.
135
+
After you've created a [`SpeechTranslationConfig`][config] instance, the next step is to initialize [`TranslationRecognizer`][recognizer]. When you initialize `TranslationRecognizer`, you need to pass it your `translationConfig` instance. The configuration object provides the credentials that the Speech service requires to validate your request.
134
136
135
-
If you're recognizing speech using your device's default microphone, here's what the [`TranslationRecognizer`][recognizer] should look like:
137
+
If you're recognizing speech by using your device's default microphone, here's what `TranslationRecognizer` should look like:
If you want to specify the audio input device, then you'll need to create an [`AudioConfig`][audioconfig] and provide the `audioConfig` parameter when initializing your [`TranslationRecognizer`][recognizer].
156
+
If you want to specify the audio input device, then you need to create an [`AudioConfig`][audioconfig]class instance and provide the `audioConfig` parameter when initializing `TranslationRecognizer`.
155
157
156
158
> [!TIP]
157
159
> [Learn how to get the device ID for your audio input device](../../../how-to-select-audio-input-devices.md).
158
160
159
-
First, you'll reference the `AudioConfig` object as follows:
161
+
First, reference the `AudioConfig` object as follows:
If you want to provide an audio file instead of using a microphone, you'll still need to provide an `audioConfig`. However, when you create an [`AudioConfig`][audioconfig], instead of calling `fromDefaultMicrophoneInput`, you'll call `fromWavFileInput` and pass the `filename` parameter.
182
+
If you want to provide an audio file instead of using a microphone, you still need to provide an `audioConfig` parameter. However, when you create an `AudioConfig` class instance, instead of calling `fromDefaultMicrophoneInput`, you call `fromWavFileInput` and pass the `filename` parameter:
To translate speech, the Speech SDK relies on a microphone or an audio file input. Speech recognition occurs before speech translation. After all objects have been initialized, call the recognize-once function and get the result.
205
+
To translate speech, the Speech SDK relies on a microphone or an audio file input. Speech recognition occurs before speech translation. After all objects have been initialized, call the recognize-once function and get the result:
@@ -232,14 +234,16 @@ For more information about speech-to-text, see [the basics of speech recognition
232
234
233
235
## Synthesize translations
234
236
235
-
After a successful speech recognition and translation, the result contains all the translations in a dictionary. The [`getTranslations`][translations] function returns a dictionary with the key as the target translation language and the value is the translated text. Recognized speech can be translated, then synthesized in a different language (speech-to-speech).
237
+
After a successful speech recognition and translation, the result contains all the translations in a dictionary. The [`getTranslations`][translations] function returns a dictionary with the key as the target translation language and the value as the translated text. Recognized speech can be translated and then synthesized in a different language (speech-to-speech).
236
238
237
239
### Event-based synthesis
238
240
239
-
The `TranslationRecognizer` object exposes a `synthesizing` event. The event fires several times, and provides a mechanism to retrieve the synthesized audio from the translation recognition result. If you're translating to multiple languages, see [manual synthesis](#manual-synthesis). Specify the synthesis voice by assigning a [`setVoiceName`][voicename] and provide an event handler for the `synthesizing` event, get the audio. The following example saves the translated audio as a *.wav* file.
241
+
The `TranslationRecognizer` object exposes a `synthesizing` event. The event fires several times and provides a mechanism to retrieve the synthesized audio from the translation recognition result. If you're translating to multiple languages, see [Manual synthesis](#manual-synthesis).
242
+
243
+
Specify the synthesis voice by assigning a [`setVoiceName`][voicename] instance, and provide an event handler for the `synthesizing` event to get the audio. The following example saves the translated audio as a .wav file.
240
244
241
245
> [!IMPORTANT]
242
-
> The event-based synthesis only works with a single translation, **do not** add multiple target translation languages. Additionally, the [`setVoiceName`][voicename]should be the same language as the target translation language, for example;`"de"` could map to `"de-DE-Hedda"`.
246
+
> The event-based synthesis works only with a single translation. *Do not* add multiple target translation languages. Additionally, the `setVoiceName` value should be the same language as the target translation language. For example,`"de"` could map to `"de-DE-Hedda"`.
The [`getTranslations`][translations] function returns a dictionary that can be used to synthesize audio from the translation text. Iterate through each translation, and synthesize the translation. When creating a `SpeechSynthesizer` instance, the `SpeechConfig` object needs to have its [`setSpeechSynthesisVoiceName`][speechsynthesisvoicename] property set to the desired voice. The following example translates to five languages, and each translation is then synthesized to an audio file in the corresponding neural language.
293
+
The [`getTranslations`][translations] function returns a dictionary that you can use to synthesize audio from the translation text. Iterate through each translation and synthesize it. When you're creating a `SpeechSynthesizer` instance, the `SpeechConfig` object needs to have its [`setSpeechSynthesisVoiceName`][speechsynthesisvoicename] property set to the desired voice.
294
+
295
+
The following example translates to five languages. Each translation is then synthesized to an audio file in the corresponding neural language.
0 commit comments