Skip to content

Commit 1f81681

Browse files
committed
faq issues
1 parent 29dfffb commit 1f81681

File tree

1 file changed

+66
-63
lines changed

1 file changed

+66
-63
lines changed

articles/cognitive-services/Speech-Service/troubleshooting.md

Lines changed: 66 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,29 @@ title: Troubleshoot the Speech SDK - Speech service
33
titleSuffix: Azure Cognitive Services
44
description: This article provides information to help you solve issues you might encounter when you use the Speech SDK.
55
services: cognitive-services
6-
author: jhakulin
6+
author: eric-urban
77
manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: speech-service
1010
ms.topic: how-to
11-
ms.date: 07/23/2019
12-
ms.author: jhakulin
11+
ms.date: 12/08/2022
12+
ms.author: eur
1313
---
1414

1515
# Troubleshoot the Speech SDK
1616

1717
This article provides information to help you solve issues you might encounter when you use the Speech SDK.
1818

19-
## Error: WebSocket Upgrade failed with an authentication error (403)
19+
## Authentication failed
2020

21-
You might have the wrong endpoint for your region or service. Check the URI to make sure it's correct.
21+
You might observe one of several authentication errors, depending on the programming environment, API, or SDK. Here are some example errors:
22+
- Did you set the speech resource key and region values?
23+
- AuthenticationFailure
24+
- HTTP 403 Forbidden or HTTP 401 Unauthorized. Connection requests without a valid `Ocp-Apim-Subscription-Key` or `Authorization` header are rejected with a status of 403 or 401.
25+
- ValueError: cannot construct SpeechConfig with the given arguments (or a variation of this message). This error could be observed, for example, when you run one of the Speech SDK for Python quickstarts without setting environment variables. You might also see it when you set the environment variables to something invalid such as your key or region.
26+
- Exception with an error code: 0x5. This access denied error could be observed, for example, when you run one of the Speech SDK for C# quickstarts without setting environment variables.
2227

23-
Also, there might be a problem with your Speech resource key or authorization token. For more information, see the next section.
24-
25-
## Error: HTTP 403 Forbidden or HTTP 401 Unauthorized
26-
27-
This error often is caused by authentication issues. Connection requests without a valid `Ocp-Apim-Subscription-Key` or `Authorization` header are rejected with a status of 403 or 401.
28-
29-
* If you're using a resource key for authentication, you might see the error because:
30-
31-
- The key is missing or invalid
32-
- You have exceeded your resource's usage quota
33-
34-
* If you're using an authorization token for authentication, you might see the error because:
35-
36-
- The authorization token is invalid
37-
- The authorization token is expired
28+
For baseline authentication troubleshooting tips, see [validate your resource key](#validate-your-resource-key) and [validate an authorization token](#validate-an-authorization-token). For more information about confirming credentials, see [get the keys for your resource](../cognitive-services-apis-create-account.md?tabs=speech#get-the-keys-for-your-resource).
3829

3930
### Validate your resource key
4031

@@ -43,80 +34,92 @@ You can verify that you have a valid resource key by running one of the followin
4334
> [!NOTE]
4435
> Replace `YOUR_RESOURCE_KEY` and `YOUR_REGION` with your own resource key and associated region.
4536
46-
* PowerShell
37+
# [PowerShell](#tab/powershell)
38+
39+
```powershell
40+
$FetchTokenHeader = @{
41+
'Content-type'='application/x-www-form-urlencoded'
42+
'Content-Length'= '0'
43+
'Ocp-Apim-Subscription-Key' = 'YOUR_RESOURCE_KEY'
44+
}
45+
$OAuthToken = Invoke-RestMethod -Method POST -Uri https://YOUR_REGION.api.cognitive.microsoft.com/sts/v1.0/issueToken -Headers $FetchTokenHeader
46+
$OAuthToken
47+
```
4748

48-
```powershell
49-
$FetchTokenHeader = @{
50-
'Content-type'='application/x-www-form-urlencoded'
51-
'Content-Length'= '0'
52-
'Ocp-Apim-Subscription-Key' = 'YOUR_RESOURCE_KEY'
53-
}
54-
$OAuthToken = Invoke-RestMethod -Method POST -Uri https://YOUR_REGION.api.cognitive.microsoft.com/sts/v1.0/issueToken -Headers $FetchTokenHeader
55-
$OAuthToken
56-
```
49+
# [cURL](#tab/curl)
5750

58-
* cURL
51+
```
52+
curl -v -X POST "https://YOUR_REGION.api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Ocp-Apim-Subscription-Key: YOUR_RESOURCE_KEY" -H "Content-type: application/x-www-form-urlencoded" -H "Content-Length: 0"
53+
```
5954

60-
```
61-
curl -v -X POST "https://YOUR_REGION.api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Ocp-Apim-Subscription-Key: YOUR_RESOURCE_KEY" -H "Content-type: application/x-www-form-urlencoded" -H "Content-Length: 0"
62-
```
55+
---
6356

6457
If you entered a valid resource key, the command returns an authorization token, otherwise an error is returned.
6558

6659
### Validate an authorization token
6760

61+
If you're using an authorization token for authentication, you might see an authentication error because:
62+
- The authorization token is invalid
63+
- The authorization token is expired
64+
6865
If you use an authorization token for authentication, run one of the following commands to verify that the authorization token is still valid. Tokens are valid for 10 minutes.
6966

7067
> [!NOTE]
7168
> Replace `YOUR_AUDIO_FILE` with the path to your prerecorded audio file. Replace `YOUR_ACCESS_TOKEN` with the authorization token returned in the preceding step. Replace `YOUR_REGION` with the correct region.
7269
73-
* PowerShell
70+
# [PowerShell](#tab/powershell)
71+
72+
```powershell
73+
$SpeechServiceURI =
74+
'https://YOUR_REGION.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?language=en-US'
7475
75-
```powershell
76-
$SpeechServiceURI =
77-
'https://YOUR_REGION.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?language=en-US'
76+
# $OAuthToken is the authorization token returned by the token service.
77+
$RecoRequestHeader = @{
78+
'Authorization' = 'Bearer '+ $OAuthToken
79+
'Transfer-Encoding' = 'chunked'
80+
'Content-type' = 'audio/wav; codec=audio/pcm; samplerate=16000'
81+
}
7882
79-
# $OAuthToken is the authorization token returned by the token service.
80-
$RecoRequestHeader = @{
81-
'Authorization' = 'Bearer '+ $OAuthToken
82-
'Transfer-Encoding' = 'chunked'
83-
'Content-type' = 'audio/wav; codec=audio/pcm; samplerate=16000'
84-
}
83+
# Read audio into byte array.
84+
$audioBytes = [System.IO.File]::ReadAllBytes("YOUR_AUDIO_FILE")
8585
86-
# Read audio into byte array.
87-
$audioBytes = [System.IO.File]::ReadAllBytes("YOUR_AUDIO_FILE")
86+
$RecoResponse = Invoke-RestMethod -Method POST -Uri $SpeechServiceURI -Headers $RecoRequestHeader -Body $audioBytes
8887
89-
$RecoResponse = Invoke-RestMethod -Method POST -Uri $SpeechServiceURI -Headers $RecoRequestHeader -Body $audioBytes
88+
# Show the result.
89+
$RecoResponse
90+
```
9091

91-
# Show the result.
92-
$RecoResponse
93-
```
92+
# [cURL](#tab/curl)
9493

95-
* cURL
94+
```
95+
curl -v -X POST "https://YOUR_REGION.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?language=en-US" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Transfer-Encoding: chunked" -H "Content-type: audio/wav; codec=audio/pcm; samplerate=16000" --data-binary @YOUR_AUDIO_FILE
96+
```
9697

97-
```
98-
curl -v -X POST "https://YOUR_REGION.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?language=en-US" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Transfer-Encoding: chunked" -H "Content-type: audio/wav; codec=audio/pcm; samplerate=16000" --data-binary @YOUR_AUDIO_FILE
99-
```
98+
---
10099

101100
If you entered a valid authorization token, the command returns the transcription for your audio file, otherwise an error is returned.
102101

103-
---
104102

105-
## Error: HTTP 400 Bad Request
103+
## InitialSilenceTimeout via RecognitionStatus
106104

107-
This error usually occurs when the request body contains invalid audio data. Only WAV format is supported. Also, check the request's headers to make sure you specify appropriate values for `Content-Type` and `Content-Length`.
105+
This issue usually is observed with [single-shot recognition](./how-to-recognize-speech.md#single-shot-recognition) of a single utterance. For example, the error can be returned under the following circumstances:
108106

109-
## Error: HTTP 408 Request Timeout
107+
* The audio begins with a long stretch of silence. In that case, the service stops the recognition after a few seconds and returns `InitialSilenceTimeout`.
108+
* The audio uses an unsupported codec format, which causes the audio data to be treated as silence.
110109

111-
The error most likely occurs because no audio data is being sent to the service. This error also might be caused by network issues.
110+
It's OK to have silence at the beginning of audio, but only when you use [continuous recognition](./how-to-recognize-speech.md#continuous-recognition).
112111

113-
## "RecognitionStatus" in the response is "InitialSilenceTimeout"
112+
## SPXERR_AUDIO_SYS_LIBRARY_NOT_FOUND
114113

115-
This issue usually is caused by audio data. You might see this error because:
114+
This can be returned, for example, when multiple versions of Python have been installed, or if you're not using a supported version of Python. You can try using a different python interpreter or uninstall all python versions and re-install the latest version of python and the Speech SDK.
116115

117-
* There's a long stretch of silence at the beginning of the audio. In that case, the service stops the recognition after a few seconds and returns `InitialSilenceTimeout`.
116+
## HTTP 400 Bad Request
118117

119-
* The audio uses an unsupported codec format, which causes the audio data to be treated as silence.
118+
This error usually occurs when the request body contains invalid audio data. Only WAV format is supported. Also, check the request's headers to make sure you specify appropriate values for `Content-Type` and `Content-Length`.
119+
120+
## HTTP 408 Request Timeout
121+
122+
The error most likely occurs because no audio data is being sent to the service. This error also might be caused by network issues.
120123

121124
## Connection closed or timeout
122125

0 commit comments

Comments
 (0)