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
Language identification is used to identify languages spoken in audio when compared against a list of [supported languages](language-support.md#language-identification).
18
+
Language identification is used to identify languages spoken in audio when compared against a list of [supported languages](language-support.md#language-identification).
19
19
20
20
Language identification (LID) use cases include:
21
21
22
22
*[Standalone language identification](#standalone-language-identification) when you only need to identify the language in an audio source.
23
-
*[Speech-to-text recognition](#speech-to-text) when you need to identify the language in an audio source and then transcribe it to text.
24
-
*[Speech translation](#speech-translation) when you need to identify the language in an audio source and then translate it to another language.
23
+
*[Speech-to-text recognition](#speech-to-text) when you need to identify the language in an audio source and then transcribe it to text.
24
+
*[Speech translation](#speech-translation) when you need to identify the language in an audio source and then translate it to another language.
25
25
26
-
Note that for speech recognition, the initial latency is higher with language identification. You should only include this optional feature as needed.
26
+
Note that for speech recognition, the initial latency is higher with language identification. You should only include this optional feature as needed.
27
27
28
28
## Configuration options
29
29
30
-
Whether you use language identification [on its own](#standalone-language-identification), with [speech-to-text](#speech-to-text), or with [speech translation](#speech-translation), there are some common concepts and configuration options.
30
+
Whether you use language identification [on its own](#standalone-language-identification), with [speech-to-text](#speech-to-text), or with [speech translation](#speech-translation), there are some common concepts and configuration options.
31
31
32
32
- Define a list of [candidate languages](#candidate-languages) that you expect in the audio.
33
33
- Decide whether to use [at-start or continuous](#at-start-and-continuous-language-identification) language identification.
34
34
- Prioritize [low latency or high accuracy](#accuracy-and-latency-prioritization) of results.
35
35
36
-
Then you make a [recognize once or continuous recognition](#recognize-once-or-continuous) request to the Speech service.
36
+
Then you make a [recognize once or continuous recognition](#recognize-once-or-continuous) request to the Speech service.
37
37
38
38
Code snippets are included with the concepts described next. Complete samples for each use case are provided further below.
39
39
40
40
### Candidate languages
41
41
42
-
You provide candidate languages, at least one of which is expected be in the audio. You can include up to 4 languages for [at-start LID](#at-start-and-continuous-language-identification) or up to 10 languages for [continuous LID](#at-start-and-continuous-language-identification).
42
+
You provide candidate languages, at least one of which is expected be in the audio. You can include up to 4 languages for [at-start LID](#at-start-and-continuous-language-identification) or up to 10 languages for [continuous LID](#at-start-and-continuous-language-identification).
43
43
44
-
You must provide the full 4-letter locale, but language identification only uses one locale per base language. Do not include multiple locales (e.g., "en-US" and "en-GB") for the same language.
44
+
You must provide the full 4-letter locale, but language identification only uses one locale per base language. Do not include multiple locales (e.g., "en-US" and "en-GB") for the same language.
For more information, see [supported languages](language-support.md#language-identification).
95
+
For more information, see [supported languages](language-support.md#language-identification).
84
96
85
97
### At-start and Continuous language identification
86
98
87
-
Speech supports both at-start and continuous language identification (LID).
99
+
Speech supports both at-start and continuous language identification (LID).
88
100
89
101
> [!NOTE]
90
102
> Continuous language identification is only supported with Speech SDKs in C#, C++, and Python.
91
-
92
103
- At-start LID identifies the language once within the first few seconds of audio. Use at-start LID if the language in the audio won't change.
93
-
- Continuous LID can identify multiple languages for the duration of the audio. Use continuous LID if the language in the audio could change. Continuous LID does not support changing languages within the same sentence. For example, if you are primarily speaking Spanish and insert some English words, it will not detect the language change per word.
104
+
- Continuous LID can identify multiple languages for the duration of the audio. Use continuous LID if the language in the audio could change. Continuous LID does not support changing languages within the same sentence. For example, if you are primarily speaking Spanish and insert some English words, it will not detect the language change per word.
94
105
95
106
You implement at-start LID or continuous LID by calling methods for [recognize once or continuous](#recognize-once-or-continuous). Results also depend upon your [Accuracy and Latency prioritization](#accuracy-and-latency-prioritization).
96
107
97
108
### Accuracy and Latency prioritization
98
109
99
-
You can choose to prioritize accuracy or latency with language identification.
110
+
You can choose to prioritize accuracy or latency with language identification.
100
111
101
112
> [!NOTE]
102
113
> Latency is prioritized by default with the Speech SDK. You can choose to prioritize accuracy or latency with the Speech SDKs for C#, C++, and Python.
114
+
Prioritize `Latency` if you need a low-latency result such as during live streaming. Set the priority to `Accuracy` if the audio quality may be poor, and more latency is acceptable. For example, a voicemail could have background noise, or some silence at the beginning. Allowing the engine more time will improve language identification results.
103
115
104
-
Prioritize `Latency` if you need a low-latency result such as during live streaming. Set the priority to `Accuracy` if the audio quality may be poor, and more latency is acceptable. For example, a voicemail could have background noise, or some silence at the beginning. Allowing the engine more time will improve language identification results.
105
-
106
-
* **At-start:** With at-start LID in `Latency` mode the result is returned in less than 5 seconds. With at-start LID in `Accuracy` mode the result is returned within 30 seconds. You set the priority for at-start LID with the `SpeechServiceConnection_SingleLanguageIdPriority` property.
107
-
* **Continuous:** With continuous LID in `Latency` mode the results are returned every 2 seconds for the duration of the audio. With continuous LID in `Accuracy` mode the results are returned within no set time frame for the duration of the audio. You set the priority for continuous LID with the `SpeechServiceConnection_ContinuousLanguageIdPriority` property.
116
+
* **At-start:** With at-start LID in `Latency` mode the result is returned in less than 5 seconds. With at-start LID in `Accuracy` mode the result is returned within 30 seconds. You set the priority for at-start LID with the `SpeechServiceConnection_SingleLanguageIdPriority` property.
117
+
* **Continuous:** With continuous LID in `Latency` mode the results are returned every 2 seconds for the duration of the audio. With continuous LID in `Accuracy` mode the results are returned within no set time frame for the duration of the audio. You set the priority for continuous LID with the `SpeechServiceConnection_ContinuousLanguageIdPriority` property.
108
118
109
119
> [!IMPORTANT]
110
120
> With [speech-to-text](#speech-to-text) and [speech translation](#speech-translation) continuous recognition, do not set `Accuracy`with the SpeechServiceConnection_ContinuousLanguageIdPriority property. The setting will be ignored without error, and the default priority of `Latency` will remain in effect. Only [standalone language identification](#standalone-language-identification) supports continuous LID with `Accuracy` prioritization.
111
-
112
-
Speech uses at-start LID with `Latency` prioritization by default. You need to set a priority property for any other LID configuration.
121
+
Speech uses at-start LID with `Latency` prioritization by default. You need to set a priority property for any other LID configuration.
113
122
114
123
::: zone pivot="programming-language-csharp"
115
124
Here is an example of using continuous LID while still prioritizing latency.
When prioritizing `Latency`, the Speech service returns one of the candidate languages provided even if those languages were not in the audio. For example, if `fr-FR` (French) and `en-US` (English) are provided as candidates, but German is spoken, either `fr-FR` or `en-US` would be returned. When prioritizing `Accuracy`, the Speech service will return the string `Unknown` as the detected language if none of the candidate languages are detected or if the language identification confidence is low.
134
149
135
150
> [!NOTE]
136
151
> You may see cases where an empty string will be returned instead of `Unknown`, due to Speech service inconsistency.
137
152
> While this note is present, applications should check for both the `Unknown` and empty string case and treat them identically.
138
-
139
153
### Recognize once or continuous
140
154
141
-
Language identification is completed with recognition objects and operations. You will make a request to the Speech service for recognition of audio.
155
+
Language identification is completed with recognition objects and operations. You will make a request to the Speech service for recognition of audio.
142
156
143
157
> [!NOTE]
144
158
> Don't confuse recognition with identification. Recognition can be used with or without language identification.
145
-
146
159
Let's map these concepts to the code. You will either call the recognize once method, or the start and stop continuous recognition methods. You choose from:
160
+
147
161
- Recognize once with at-start LID
148
162
- Continuous recognition with at start LID
149
-
- Continuous recognition with continuous LID
163
+
- Continuous recognition with continuous LID
150
164
151
-
The `SpeechServiceConnection_ContinuousLanguageIdPriority` property is always required for continuous LID. Without it the speech service defaults to at-start lid.
165
+
The `SpeechServiceConnection_ContinuousLanguageIdPriority` property is always required for continuous LID. Without it the speech service defaults to at-start lid.
@@ -235,39 +252,31 @@ See more examples of standalone language identification on [GitHub](https://gith
235
252
236
253
See more examples of standalone language identification on [GitHub](https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/cpp/windows/console/samples/standalone_language_detection_samples.cpp).
See more examples of standalone language identification on [GitHub](https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/python/console/speech_language_detection_sample.py).
257
270
258
-
259
271
::: zone-end
260
272
261
-
262
273
## Speech-to-text
263
274
264
275
You use Speech-to-text recognition when you need to identify the language in an audio source and then transcribe it to text. For more information, see [Speech-to-text overview](speech-to-text.md).
265
276
266
277
> [!NOTE]
267
278
> Speech-to-text recognition with at-start language identification is supported with Speech SDKs in C#, C++, Python, Java, JavaScript, and Objective-C. Speech-to-text recognition with continuous language identification is only supported with Speech SDKs in C#, C++, and Python.
268
-
>
269
279
> Currently for speech-to-text recognition with continuous language identification, you must create a SpeechConfig from the `wss://{region}.stt.speech.microsoft.com/speech/universal/v2` endpoint string, as shown in code examples. In a future SDK release you won't need to set it.
270
-
271
280
::: zone pivot="programming-language-csharp"
272
281
273
282
### [Recognize once](#tab/once)
@@ -389,7 +398,6 @@ See more examples of speech-to-text recognition with language identification on
389
398
390
399
::: zone pivot="programming-language-cpp"
391
400
392
-
393
401
### [Recognize once](#tab/once)
394
402
395
403
```cpp
@@ -414,14 +422,12 @@ auto autoDetectSourceLanguageResult =
414
422
auto detectedLanguage = autoDetectSourceLanguageResult->Language;
See more examples of speech-to-text recognition with language identification on [GitHub](https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/cpp/windows/console/samples/speech_recognition_samples.cpp).
423
430
424
-
425
431
::: zone-end
426
432
427
433
::: zone pivot="programming-language-java"
@@ -454,7 +460,6 @@ See more examples of speech-to-text recognition with language identification on
@@ -647,19 +648,15 @@ var autoDetectSourceLanguageConfig = SpeechSDK.AutoDetectSourceLanguageConfig.fr
647
648
648
649
::: zone-end
649
650
650
-
651
651
## Speech translation
652
652
653
653
You use Speech translation when you need to identify the language in an audio source and then translate it to another language. For more information, see [Speech translation overview](speech-translation.md).
654
654
655
655
> [!NOTE]
656
656
> Speech translation with language identification is only supported with Speech SDKs inC#, C++, and Python.
657
-
>
658
657
> Currently for speech translation with language identification, you must create a SpeechConfig from the `wss://{region}.stt.speech.microsoft.com/speech/universal/v2` endpoint string, as shown in code examples. In a future SDK release you won't need to set it.
659
-
660
658
::: zone pivot="programming-language-csharp"
661
659
662
-
663
660
### [Recognize once](#tab/once)
664
661
665
662
```csharp
@@ -991,7 +988,6 @@ See more examples of speech translation with language identification on [GitHub]
0 commit comments