Skip to content

Commit 5a38e95

Browse files
authored
Merge pull request #41643 from Jann-Skotdal/master
Speech reference and dictionary example
2 parents 76de364 + a08446e commit 5a38e95

File tree

6 files changed

+394
-14
lines changed

6 files changed

+394
-14
lines changed

articles/cognitive-services/Translator/dynamic-dictionary.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ If you already know the translation you want to apply to a word or a phrase, you
2121

2222
**Example: en-de:**
2323

24-
Source input: Instant dictionary: word <mstrans:dictionary translation=”wordomatic”>word or phrase</mstrans:dictionary> is a dictionary entry.
25-
26-
Target output: Sofortige Wörterbuch: Wort "wordomatic" ist einen Wörterbucheintrag.
24+
Source input: The word <mstrans:dictionary translation=\"wordomatic\">word or phrase</mstrans:dictionary> is a dictionary entry.
2725

26+
Target output: Das Wort "wordomatic" ist ein Wörterbucheintrag.
2827

2928
This feature works the same way with and without HTML mode.
3029

articles/cognitive-services/Translator/reference/v3-0-translate.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,10 @@ The markup to supply uses the following syntax.
523523
<mstrans:dictionary translation=”translation of phrase”>phrase</mstrans:dictionary>
524524
```
525525

526-
For example, consider the English sentence "Instant dictionary: word wordomatic is a dictionary entry." To preserve the word _wordomatic_ in the translation, send the request:
526+
For example, consider the English sentence "The word wordomatic is a dictionary entry." To preserve the word _wordomatic_ in the translation, send the request:
527527

528528
```
529-
curl -X POST "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=de" -H "Ocp-Apim-Subscription-Key: <client-secret>" -H "Content-Type: application/json" -d "[{'Text':'Instant dictionary: word <mstrans:dictionary translation=\"wordomatic\">word or phrase</mstrans:dictionary> is a dictionary entry.'}]"
529+
curl -X POST "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=de" -H "Ocp-Apim-Subscription-Key: <client-secret>" -H "Content-Type: application/json" -d "[{'Text':'The word <mstrans:dictionary translation=\"wordomatic\">word or phrase</mstrans:dictionary> is a dictionary entry.'}]"
530530
```
531531

532532
The result is:
@@ -535,7 +535,7 @@ The result is:
535535
[
536536
{
537537
"translations":[
538-
{"text":"Sofortige Wörterbuch: Wort wordomatic ist ein Wörterbucheintrag.","to":"de"}
538+
{"text":"Das Wort "wordomatic" ist ein Wörterbucheintrag.","to":"de"}
539539
]
540540
}
541541
]
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
---
2+
title: Microsoft Translator Speech API Languages Method | Microsoft Docs
3+
titleSuffix: Cognitive Services
4+
description: Use the Microsoft Translator Speech API Languages method.
5+
services: cognitive-services
6+
author: Jann-Skotdal
7+
manager: chriswendt1
8+
9+
ms.service: cognitive-services
10+
ms.technology: microsoft translator
11+
ms.topic: article
12+
ms.date: 05/18/18
13+
ms.author: v-jansko
14+
---
15+
16+
# Speech API: Languages
17+
18+
Microsoft Translator continually extends the list of languages supported by its services. Use this API to discover the set of languages currently available for use with the Speech Translation service.
19+
20+
Code samples demonstrating use of the API to get available languages are available from the [Microsoft Translator Github site](https://github.com/MicrosoftTranslator).
21+
22+
## Implementation notes
23+
24+
GET /languages
25+
26+
A wide set of languages is available to transcribe speech, to translate the transcribed text, and to produce synthesized speech of the translation.
27+
28+
A client uses the `scope` query parameter to define which sets of languages it is interested in.
29+
30+
* **Speech-to-text:** Use query parameter `scope=speech` to retrieve the set of languages available to transcribe speech into text.
31+
* **Text translation:** Use query parameter `scope=text` to retrieve the set of languages available to translate transcribed text.
32+
* **Text-to-speech:** Use query parameter `scope=tts` to retrieve the set of languages and voices available to synthesize translated text back into speech.
33+
34+
A client can retrieve multiple sets simultaneously by specifying a comma-separated list of choices. For example, `scope=speech,text,tts`.
35+
36+
A successful response is a JSON object with a property for each requested set.
37+
38+
```
39+
{
40+
"speech": {
41+
//... Set of languages supported for speech-to-text
42+
},
43+
"text": {
44+
//... Set of languages supported for text translation
45+
},
46+
"tts": {
47+
//... Set of languages supported for text-to-speech
48+
}
49+
}
50+
```
51+
52+
Since a client can use the `scope` query parameter to select which sets of supported languages should be returned, an actual response may only include a subset of all properties shown above.
53+
54+
The value provided with each property is as follows.
55+
56+
### Speech-to-text (speech)
57+
58+
The value associated with the speech-to-text property, `speech`, is a dictionary of (key, value) pairs. Each key identifies a language supported for speech-to-text. The key is the identifier that client passes to the API. The value associated with the key is an object with the following properties:
59+
60+
* `name`: Display name of the language.
61+
* `language`: Language tag of the associated written language. See "Text transation" below.
62+
An example is:
63+
64+
```
65+
{
66+
"speech": {
67+
"en-US": { name: "English", language: "en" }
68+
}
69+
}
70+
```
71+
72+
### Text translation (text)
73+
74+
The value associated with the `text` property is also a dictionary where each key identifies a language supported for text translation. The value associated with the key describes the language:
75+
76+
* `name`: Display name of the language.
77+
* `dir`: Directionality which is `rtl` for right-to-left languages or `ltr` for left-to-right languages.
78+
79+
An example is:
80+
81+
```
82+
{
83+
"text": {
84+
"en": { name: "English", dir: "ltr" }
85+
}
86+
}
87+
```
88+
89+
### Text-to-speech (tts)
90+
91+
The value associated with the text-to-speech property, tts, is also a dictionary where each key identifies a supported voice. Attributes of a voice object are:
92+
93+
* `displayName`: Display name for the voice.
94+
* `gender`: Gender of the voice (male or female).
95+
* `locale`: Language tag of the voice with primary language subtag and region subtag.
96+
* `language`: Language tag of the associated written language.
97+
* `languageName`: Display name of the language.
98+
* `regionName`: Display name of the region for this language.
99+
100+
An example is:
101+
102+
```
103+
{
104+
"tts": {
105+
"en-US-Zira": {
106+
"displayName": "Zira",
107+
"gender": "female",
108+
"locale": "en-US",
109+
"languageName": "English",
110+
"regionName": "United States",
111+
"language": "en"
112+
}
113+
}
114+
```
115+
116+
### Localization
117+
The service returns all names in the language of the 'Accept-Language' header, for all the languages supported in text translation.
118+
119+
### Response class (Status 200)
120+
Object describing the set of supported languages.
121+
122+
ModelExample Value:
123+
124+
Langagues {
125+
speech (object, optional),
126+
text (object, optional),
127+
tts (object, optional)
128+
}
129+
130+
### Headers
131+
132+
|Header|Description|Type|
133+
:--|:--|:--|
134+
X-RequestId|Value generated by server to identify the request and used for troubleshooting purposes.|string|
135+
136+
### Parameters
137+
138+
|Parameter|Description|Parameter Type|Data Type|
139+
|:--|:--|:--|:--|
140+
|api-version |Version of the API requested by the client. Allowed values are: `1.0`.|query|string|
141+
|scope |Sets of supported languages or voices to return to the client. This parameter is specified as a comma-separated list of keywords. The following keywords are available:<ul><li>`speech`: Provides the set of languages supported to transcribe speech.</li><li>`tts`: Provides the set of voices supported for text-speech conversion.</li><li>`text`: Provides the set of languages supported for translating text.</li></ul>If a value is not specified, the value of `scope` defaults to `text`.|query|string|
142+
|X-ClientTraceId |A client-generated GUID used to trace a request. To facilitate troubleshooting of issues, clients should provide a new value with each request and log it.|header|string|
143+
|Accept-Language |Some of the fields in the response are names of languages or regions. Use this parameter to define the language in which names are returned. The language is specified by providing a well-formed BCP 47 language tag. Select a tag from the list of language identifiers returned with the `text` scope. For unsupported languages, the names are provided in the English language.<br/>For instance, use the value `fr` to request names in French or use the value `zh-Hant` to request names in Chinese Traditional.|header|string|
144+
145+
### Response messages
146+
147+
|HTTP Status Code|Reason|
148+
|:--|:--|
149+
|400|Bad request. Check input parameters to ensure they are valid. The response object includes a more detailed description of the error.|
150+
|429|Too many requests.|
151+
|500|An error occured. If the error persists, please report it with client trace identifier (X-ClientTraceId) or request identifier (X-RequestId).|
152+
|503|Server temporarily unavailable. Please retry the request. If the error persists, please report it with client trace identifier (X-ClientTraceId) or request identifier (X-RequestId).|

articles/cognitive-services/translator-speech/languages.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ The Microsoft Translator Speech API supports the following languages as a target
5656
| Hindi | `hi` |
5757
| Hmong Daw | `mww` |
5858
| Hungarian | `hu` |
59+
|Icelandic|`is` |
5960
| Indonesian | `id` |
6061
| Italian | `it` |
6162
| Japanese | `ja` |
@@ -95,13 +96,11 @@ The Microsoft Translator Speech API supports the following languages as a target
9596

9697
## Access the list programmatically
9798

98-
You can access the list of supported languages programmatically using the Languages resource. The list provides the language code as well as the language name in English, or any other supported language. This list is automatically updated by the Microsoft Translator service as new languages become available.
99+
You can access the list of supported languages programmatically using the languages resource. The list provides the language code as well as the language name in English, or any other supported language. This list is automatically updated by the Microsoft Translator service as new languages become available.
99100

100-
The Languages resource returns the list of supported languages for text and speech translation. The Languages resource does not require authentication.
101+
The Languages resource returns the list of supported languages for speech, text, and text to speech. The Languages resource does not require authentication.
101102

102-
To access the list, add 'text' in the 'Scope' parameter of the Languages resource reference page. After you have entered the scope parameter, select the **Try it out!** button. The service returns the supported languages in JSON format. The response is visible in the 'Response Body' section.
103-
104-
[Visit the API reference to try out the languages method](http://docs.microsofttranslator.com/languages.html)
103+
[Visit the API reference to try out the languages method](languages-reference.md)
105104

106105
## Access the list on the Microsoft Translator website
107106

0 commit comments

Comments
 (0)