|
| 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).| |
0 commit comments