Skip to content

Commit fb77219

Browse files
committed
Updated REST doc with CID
1 parent 2d0b80a commit fb77219

File tree

2 files changed

+42
-34
lines changed

2 files changed

+42
-34
lines changed

.vscode/settings.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,20 @@
5757
],
5858
"cSpell.words": [
5959
"auditd"
60-
]
60+
],
61+
"workbench.colorCustomizations": {
62+
"activityBar.background": "#d04649",
63+
"activityBar.activeBorder": "#37cb34",
64+
"activityBar.foreground": "#e7e7e7",
65+
"activityBar.inactiveForeground": "#e7e7e799",
66+
"activityBarBadge.background": "#37cb34",
67+
"activityBarBadge.foreground": "#15202b",
68+
"titleBar.activeBackground": "#b52e31",
69+
"titleBar.inactiveBackground": "#b52e3199",
70+
"titleBar.activeForeground": "#e7e7e7",
71+
"titleBar.inactiveForeground": "#e7e7e799",
72+
"statusBar.background": "#b52e31",
73+
"statusBarItem.hoverBackground": "#d04649",
74+
"statusBar.foreground": "#e7e7e7"
75+
}
6176
}

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

Lines changed: 26 additions & 33 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: 03/02/2020
11+
ms.date: 03/03/2020
1212
ms.author: erhopf
1313
---
1414

@@ -49,7 +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 reference those models with the custom identifer (`cid`). | 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 |
5353

5454
## Request headers
5555

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

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

71-
| Format | Codec | Bitrate | Sample Rate |
72-
|--------|-------|---------|-------------|
73-
| WAV | PCM | 16-bit | 16 kHz, mono |
74-
| 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 |
7575

7676
>[!NOTE]
7777
>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).
@@ -96,50 +96,43 @@ The HTTP status code for each response indicates success or common errors.
9696

9797
| HTTP status code | Description | Possible reason |
9898
|------------------|-------------|-----------------|
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. |
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. |
104104

105105
## Chunked transfer
106106

107107
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.
108108

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.
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.
110110

111111
```csharp
112-
113-
HttpWebRequest request = null;
114-
request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
115-
request.SendChunked = true;
116-
request.Accept = @"application/json;text/xml";
117-
request.Method = "POST";
118-
request.ProtocolVersion = HttpVersion.Version11;
119-
request.Host = host;
120-
request.ContentType = @"audio/wav; codecs=audio/pcm; samplerate=16000";
121-
request.Headers["Ocp-Apim-Subscription-Key"] = args[1];
122-
request.AllowWriteStreamBuffering = false;
123-
124-
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))
125123
{
126-
/*
127-
* Open a request stream and write 1024 byte chunks in the stream one at a time.
128-
*/
124+
// Open a request stream and write 1024 byte chunks in the stream one at a time.
129125
byte[] buffer = null;
130126
int bytesRead = 0;
131-
using (Stream requestStream = request.GetRequestStream())
127+
using (var requestStream = request.GetRequestStream())
132128
{
133-
/*
134-
* Read 1024 raw bytes from the input audio file.
135-
*/
129+
// Read 1024 raw bytes from the input audio file.
136130
buffer = new Byte[checked((uint)Math.Min(1024, (int)fs.Length))];
137131
while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0)
138132
{
139133
requestStream.Write(buffer, 0, bytesRead);
140134
}
141135

142-
// Flush
143136
requestStream.Flush();
144137
}
145138
}

0 commit comments

Comments
 (0)