Skip to content

Commit 6d97f3a

Browse files
authored
Merge pull request #106296 from IEvangelist/cidWithREST
Update REST doc to include the CID query string parameter
2 parents 12b176b + 1812d86 commit 6d97f3a

File tree

1 file changed

+26
-32
lines changed

1 file changed

+26
-32
lines changed

articles/cognitive-services/Speech-Service/rest-speech-to-text.md

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: speech-service
1010
ms.topic: conceptual
11-
ms.date: 12/09/2019
11+
ms.date: 03/03/2020
1212
ms.author: erhopf
1313
---
1414

@@ -49,6 +49,7 @@ These parameters may be included in the query string of the REST request.
4949
| `language` | Identifies the spoken language that is being recognized. See [Supported languages](language-support.md#speech-to-text). | Required |
5050
| `format` | Specifies the result format. Accepted values are `simple` and `detailed`. Simple results include `RecognitionStatus`, `DisplayText`, `Offset`, and `Duration`. Detailed responses include multiple results with confidence values and four different representations. The default setting is `simple`. | Optional |
5151
| `profanity` | Specifies how to handle profanity in recognition results. Accepted values are `masked`, which replaces profanity with asterisks, `removed`, which removes all profanity from the result, or `raw`, which includes the profanity in the result. The default setting is `masked`. | Optional |
52+
| `cid` | When using the [Custom Speech portal](how-to-custom-speech.md) to create custom models, you can use custom models via their **Endpoint ID** found on the **Deployment** page. Use the **Endpoint ID** as the argument to the `cid` query string parameter. | Optional |
5253

5354
## Request headers
5455

@@ -67,10 +68,10 @@ This table lists required and optional headers for speech-to-text requests.
6768

6869
Audio is sent in the body of the HTTP `POST` request. It must be in one of the formats in this table:
6970

70-
| Format | Codec | Bitrate | Sample Rate |
71-
|--------|-------|---------|-------------|
72-
| WAV | PCM | 16-bit | 16 kHz, mono |
73-
| OGG | OPUS | 16-bit | 16 kHz, mono |
71+
| Format | Codec | Bitrate | Sample Rate |
72+
|--------|-------|---------|--------------|
73+
| WAV | PCM | 16-bit | 16 kHz, mono |
74+
| OGG | OPUS | 16-bit | 16 kHz, mono |
7475

7576
>[!NOTE]
7677
>The above formats are supported through REST API and WebSocket in the Speech service. The [Speech SDK](speech-sdk.md) currently supports the WAV format with PCM codec as well as [other formats](how-to-use-codec-compressed-audio-input-streams.md).
@@ -95,50 +96,43 @@ The HTTP status code for each response indicates success or common errors.
9596

9697
| HTTP status code | Description | Possible reason |
9798
|------------------|-------------|-----------------|
98-
| 100 | Continue | The initial request has been accepted. Proceed with sending the rest of the data. (Used with chunked transfer.) |
99-
| 200 | OK | The request was successful; the response body is a JSON object. |
100-
| 400 | Bad request | Language code not provided, not a supported language, invalid audio file, etc. |
101-
| 401 | Unauthorized | Subscription key or authorization token is invalid in the specified region, or invalid endpoint. |
102-
| 403 | Forbidden | Missing subscription key or authorization token. |
99+
| `100` | Continue | The initial request has been accepted. Proceed with sending the rest of the data. (Used with chunked transfer) |
100+
| `200` | OK | The request was successful; the response body is a JSON object. |
101+
| `400` | Bad request | Language code not provided, not a supported language, invalid audio file, etc. |
102+
| `401` | Unauthorized | Subscription key or authorization token is invalid in the specified region, or invalid endpoint. |
103+
| `403` | Forbidden | Missing subscription key or authorization token. |
103104

104105
## Chunked transfer
105106

106107
Chunked transfer (`Transfer-Encoding: chunked`) can help reduce recognition latency. It allows the Speech service to begin processing the audio file while it is transmitted. The REST API does not provide partial or interim results.
107108

108-
This code sample shows how to send audio in chunks. Only the first chunk should contain the audio file's header. `request` is an HTTPWebRequest object connected to the appropriate REST endpoint. `audioFile` is the path to an audio file on disk.
109+
This code sample shows how to send audio in chunks. Only the first chunk should contain the audio file's header. `request` is an `HttpWebRequest` object connected to the appropriate REST endpoint. `audioFile` is the path to an audio file on disk.
109110

110111
```csharp
111-
112-
HttpWebRequest request = null;
113-
request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
114-
request.SendChunked = true;
115-
request.Accept = @"application/json;text/xml";
116-
request.Method = "POST";
117-
request.ProtocolVersion = HttpVersion.Version11;
118-
request.Host = host;
119-
request.ContentType = @"audio/wav; codecs=audio/pcm; samplerate=16000";
120-
request.Headers["Ocp-Apim-Subscription-Key"] = args[1];
121-
request.AllowWriteStreamBuffering = false;
122-
123-
using (fs = new FileStream(audioFile, FileMode.Open, FileAccess.Read))
112+
var request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
113+
request.SendChunked = true;
114+
request.Accept = @"application/json;text/xml";
115+
request.Method = "POST";
116+
request.ProtocolVersion = HttpVersion.Version11;
117+
request.Host = host;
118+
request.ContentType = @"audio/wav; codecs=audio/pcm; samplerate=16000";
119+
request.Headers["Ocp-Apim-Subscription-Key"] = "YOUR_SUBSCRIPTION_KEY";
120+
request.AllowWriteStreamBuffering = false;
121+
122+
using (var fs = new FileStream(audioFile, FileMode.Open, FileAccess.Read))
124123
{
125-
/*
126-
* Open a request stream and write 1024 byte chunks in the stream one at a time.
127-
*/
124+
// Open a request stream and write 1024 byte chunks in the stream one at a time.
128125
byte[] buffer = null;
129126
int bytesRead = 0;
130-
using (Stream requestStream = request.GetRequestStream())
127+
using (var requestStream = request.GetRequestStream())
131128
{
132-
/*
133-
* Read 1024 raw bytes from the input audio file.
134-
*/
129+
// Read 1024 raw bytes from the input audio file.
135130
buffer = new Byte[checked((uint)Math.Min(1024, (int)fs.Length))];
136131
while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0)
137132
{
138133
requestStream.Write(buffer, 0, bytesRead);
139134
}
140135

141-
// Flush
142136
requestStream.Flush();
143137
}
144138
}

0 commit comments

Comments
 (0)