Skip to content

Commit 0e9299c

Browse files
author
Qi Ding
committed
update sample code with endpoint api usage in git doc repo
1 parent 9191ef5 commit 0e9299c

File tree

16 files changed

+78
-74
lines changed

16 files changed

+78
-74
lines changed

articles/ai-services/speech-service/includes/quickstarts/speech-to-text-basics/cpp.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ Follow these steps to create a console application and install the Speech SDK.
5151
5252
int main()
5353
{
54-
// This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
54+
// This example requires environment variables named "SPEECH_KEY" and "END_POINT"
5555
auto speechKey = GetEnvironmentVariable("SPEECH_KEY");
56-
auto speechRegion = GetEnvironmentVariable("SPEECH_REGION");
56+
auto endPoint = GetEnvironmentVariable("END_POINT");
5757
58-
if ((size(speechKey) == 0) || (size(speechRegion) == 0)) {
59-
std::cout << "Please set both SPEECH_KEY and SPEECH_REGION environment variables." << std::endl;
58+
if ((size(speechKey) == 0) || (size(endPoint) == 0)) {
59+
std::cout << "Please set both SPEECH_KEY and END_POINT environment variables." << std::endl;
6060
return -1;
6161
}
6262
63-
auto speechConfig = SpeechConfig::FromSubscription(speechKey, speechRegion);
63+
auto speechConfig = SpeechConfig::FromEndpoint(speechKey, endPoint);
6464
6565
speechConfig->SetSpeechRecognitionLanguage("en-US");
6666
@@ -87,7 +87,7 @@ Follow these steps to create a console application and install the Speech SDK.
8787
{
8888
std::cout << "CANCELED: ErrorCode=" << (int)cancellation->ErrorCode << std::endl;
8989
std::cout << "CANCELED: ErrorDetails=" << cancellation->ErrorDetails << std::endl;
90-
std::cout << "CANCELED: Did you set the speech resource key and region values?" << std::endl;
90+
std::cout << "CANCELED: Did you set the speech resource key and endpoint values?" << std::endl;
9191
}
9292
}
9393
}
@@ -116,7 +116,7 @@ Follow these steps to create a console application and install the Speech SDK.
116116
1. [Build and run](/cpp/build/vscpp-step-2-build) your new console application to start speech recognition from a microphone.
117117

118118
> [!IMPORTANT]
119-
> Make sure that you set the `SPEECH_KEY` and `SPEECH_REGION` [environment variables](#set-environment-variables). If you don't set these variables, the sample fails with an error message.
119+
> Make sure that you set the `SPEECH_KEY` and `END_POINT` [environment variables](#set-environment-variables). If you don't set these variables, the sample fails with an error message.
120120
121121
1. Speak into your microphone when prompted. What you speak should appear as text:
122122

articles/ai-services/speech-service/includes/quickstarts/speech-to-text-basics/csharp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Follow these steps to create a console application and install the Speech SDK.
7676
{
7777
Console.WriteLine($"CANCELED: ErrorCode={cancellation.ErrorCode}");
7878
Console.WriteLine($"CANCELED: ErrorDetails={cancellation.ErrorDetails}");
79-
Console.WriteLine($"CANCELED: Did you set the speech resource key and region values?");
79+
Console.WriteLine($"CANCELED: Did you set the speech resource key and endpoint values?");
8080
}
8181
break;
8282
}

articles/ai-services/speech-service/includes/quickstarts/speech-to-text-basics/java.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ Follow these steps to create a console application for speech recognition.
7575
import java.util.concurrent.Future;
7676

7777
public class SpeechRecognition {
78-
// This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
78+
// This example requires environment variables named "SPEECH_KEY" and "END_POINT"
7979
private static String speechKey = System.getenv("SPEECH_KEY");
80-
private static String speechRegion = System.getenv("SPEECH_REGION");
80+
private static String endPoint = System.getenv("END_POINT");
8181

8282
public static void main(String[] args) throws InterruptedException, ExecutionException {
83-
SpeechConfig speechConfig = SpeechConfig.fromSubscription(speechKey, speechRegion);
83+
SpeechConfig speechConfig = SpeechConfig.fromEndpoint(speechKey, endPoint);
8484
speechConfig.setSpeechRecognitionLanguage("en-US");
8585
recognizeFromMicrophone(speechConfig);
8686
}
@@ -106,7 +106,7 @@ Follow these steps to create a console application for speech recognition.
106106
if (cancellation.getReason() == CancellationReason.Error) {
107107
System.out.println("CANCELED: ErrorCode=" + cancellation.getErrorCode());
108108
System.out.println("CANCELED: ErrorDetails=" + cancellation.getErrorDetails());
109-
System.out.println("CANCELED: Did you set the speech resource key and region values?");
109+
System.out.println("CANCELED: Did you set the speech resource key and endpoint values?");
110110
}
111111
}
112112

@@ -125,7 +125,7 @@ Follow these steps to create a console application for speech recognition.
125125
```
126126

127127
> [!IMPORTANT]
128-
> Make sure that you set the `SPEECH_KEY` and `SPEECH_REGION` [environment variables](#set-environment-variables). If you don't set these variables, the sample fails with an error message.
128+
> Make sure that you set the `SPEECH_KEY` and `END_POINT` [environment variables](#set-environment-variables). If you don't set these variables, the sample fails with an error message.
129129
130130
1. Speak into your microphone when prompted. What you speak should appear as text:
131131

articles/ai-services/speech-service/includes/quickstarts/speech-to-text-basics/python.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ Follow these steps to create a console application.
4949
import azure.cognitiveservices.speech as speechsdk
5050

5151
def recognize_from_microphone():
52-
# This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
53-
speech_config = speechsdk.SpeechConfig(subscription=os.environ.get('SPEECH_KEY'), region=os.environ.get('SPEECH_REGION'))
52+
# This example requires environment variables named "SPEECH_KEY" and "END_POINT"
53+
# Replace with your own subscription key and endpoint, the endpoint is like : "https://YourServiceRegion.api.cognitive.microsoft.com"
54+
speech_config = speechsdk.SpeechConfig(subscription=os.environ.get('SPEECH_KEY'), endpoint=os.environ.get('END_POINT'))
5455
speech_config.speech_recognition_language="en-US"
5556

5657
audio_config = speechsdk.audio.AudioConfig(use_default_microphone=True)
@@ -68,7 +69,7 @@ Follow these steps to create a console application.
6869
print("Speech Recognition canceled: {}".format(cancellation_details.reason))
6970
if cancellation_details.reason == speechsdk.CancellationReason.Error:
7071
print("Error details: {}".format(cancellation_details.error_details))
71-
print("Did you set the speech resource key and region values?")
72+
print("Did you set the speech resource key and endpoint values?")
7273

7374
recognize_from_microphone()
7475
```
@@ -82,7 +83,7 @@ Follow these steps to create a console application.
8283
```
8384

8485
> [!IMPORTANT]
85-
> Make sure that you set the `SPEECH_KEY` and `SPEECH_REGION` [environment variables](#set-environment-variables). If you don't set these variables, the sample fails with an error message.
86+
> Make sure that you set the `SPEECH_KEY` and `END_POINT` [environment variables](#set-environment-variables). If you don't set these variables, the sample fails with an error message.
8687
8788
1. Speak into your microphone when prompted. What you speak should appear as text:
8889

articles/ai-services/speech-service/includes/quickstarts/speech-translation-basics/cpp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ Follow these steps to create a new console application and install the Speech SD
4545
4646
int main()
4747
{
48-
// This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
48+
// This example requires environment variables named "SPEECH_KEY" and "END_POINT"
4949
auto speechKey = GetEnvironmentVariable("SPEECH_KEY");
50-
auto speechRegion = GetEnvironmentVariable("SPEECH_REGION");
50+
auto endPoint = GetEnvironmentVariable("END_POINT");
5151
52-
auto speechTranslationConfig = SpeechTranslationConfig::FromSubscription(speechKey, speechRegion);
52+
auto speechTranslationConfig = SpeechTranslationConfig::FromEndpoint(speechKey, endPoint);
5353
speechTranslationConfig->SetSpeechRecognitionLanguage("en-US");
5454
speechTranslationConfig->AddTargetLanguage("it");
5555
@@ -82,7 +82,7 @@ Follow these steps to create a new console application and install the Speech SD
8282
{
8383
std::cout << "CANCELED: ErrorCode=" << (int)cancellation->ErrorCode << std::endl;
8484
std::cout << "CANCELED: ErrorDetails=" << cancellation->ErrorDetails << std::endl;
85-
std::cout << "CANCELED: Did you set the speech resource key and region values?" << std::endl;
85+
std::cout << "CANCELED: Did you set the speech resource key and endpoint values?" << std::endl;
8686
}
8787
}
8888
}

articles/ai-services/speech-service/includes/quickstarts/speech-translation-basics/csharp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The Speech SDK is available as a [NuGet package](https://www.nuget.org/packages/
1919

2020
### Set environment variables
2121

22-
[!INCLUDE [Environment variables](../../common/environment-variables.md)]
22+
[!INCLUDE [Environment variables](../../common/environment-variables-endpoint-key.md)]
2323

2424
## Translate speech from a microphone
2525

@@ -45,9 +45,9 @@ Follow these steps to create a new console application and install the Speech SD
4545
4646
class Program
4747
{
48-
// This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
48+
// This example requires environment variables named "SPEECH_KEY" and "END_POINT"
4949
static string speechKey = Environment.GetEnvironmentVariable("SPEECH_KEY");
50-
static string speechRegion = Environment.GetEnvironmentVariable("SPEECH_REGION");
50+
static string endPoint = Environment.GetEnvironmentVariable("END_POINT");
5151
5252
static void OutputSpeechRecognitionResult(TranslationRecognitionResult translationRecognitionResult)
5353
{
@@ -71,15 +71,15 @@ Follow these steps to create a new console application and install the Speech SD
7171
{
7272
Console.WriteLine($"CANCELED: ErrorCode={cancellation.ErrorCode}");
7373
Console.WriteLine($"CANCELED: ErrorDetails={cancellation.ErrorDetails}");
74-
Console.WriteLine($"CANCELED: Did you set the speech resource key and region values?");
74+
Console.WriteLine($"CANCELED: Did you set the speech resource key and endpoint values?");
7575
}
7676
break;
7777
}
7878
}
7979
8080
async static Task Main(string[] args)
8181
{
82-
var speechTranslationConfig = SpeechTranslationConfig.FromSubscription(speechKey, speechRegion);
82+
var speechTranslationConfig = SpeechTranslationConfig.FromEndpoint(speechKey, endPoint);
8383
speechTranslationConfig.SpeechRecognitionLanguage = "en-US";
8484
speechTranslationConfig.AddTargetLanguage("it");
8585

articles/ai-services/speech-service/includes/quickstarts/speech-translation-basics/java.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ Follow these steps to create a new console application for speech recognition.
7474
import java.util.Map;
7575

7676
public class SpeechTranslation {
77-
// This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
77+
// This example requires environment variables named "SPEECH_KEY" and "END_POINT"
7878
private static String speechKey = System.getenv("SPEECH_KEY");
79-
private static String speechRegion = System.getenv("SPEECH_REGION");
79+
private static String endPoint = System.getenv("END_POINT");
8080

8181
public static void main(String[] args) throws InterruptedException, ExecutionException {
82-
SpeechTranslationConfig speechTranslationConfig = SpeechTranslationConfig.fromSubscription(speechKey, speechRegion);
82+
SpeechTranslationConfig speechTranslationConfig = SpeechTranslationConfig.fromEndpoint(speechKey, endPoint);
8383
speechTranslationConfig.setSpeechRecognitionLanguage("en-US");
8484

8585
String[] toLanguages = { "it" };
@@ -114,7 +114,7 @@ Follow these steps to create a new console application for speech recognition.
114114
if (cancellation.getReason() == CancellationReason.Error) {
115115
System.out.println("CANCELED: ErrorCode=" + cancellation.getErrorCode());
116116
System.out.println("CANCELED: ErrorDetails=" + cancellation.getErrorDetails());
117-
System.out.println("CANCELED: Did you set the speech resource key and region values?");
117+
System.out.println("CANCELED: Did you set the speech resource key and endpoint values?");
118118
}
119119
}
120120

articles/ai-services/speech-service/includes/quickstarts/speech-translation-basics/python.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ Follow these steps to create a new console application.
4242
import azure.cognitiveservices.speech as speechsdk
4343
4444
def recognize_from_microphone():
45-
# This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
46-
speech_translation_config = speechsdk.translation.SpeechTranslationConfig(subscription=os.environ.get('SPEECH_KEY'), region=os.environ.get('SPEECH_REGION'))
45+
# This example requires environment variables named "SPEECH_KEY" and "END_POINT"
46+
# Replace with your own subscription key and endpoint, the endpoint is like : "https://YourServiceRegion.api.cognitive.microsoft.com"
47+
speech_translation_config = speechsdk.translation.SpeechTranslationConfig(subscription=os.environ.get('SPEECH_KEY'), endpoint=os.environ.get('END_POINT'))
4748
speech_translation_config.speech_recognition_language="en-US"
4849
4950
to_language ="it"
@@ -67,7 +68,7 @@ Follow these steps to create a new console application.
6768
print("Speech Recognition canceled: {}".format(cancellation_details.reason))
6869
if cancellation_details.reason == speechsdk.CancellationReason.Error:
6970
print("Error details: {}".format(cancellation_details.error_details))
70-
print("Did you set the speech resource key and region values?")
71+
print("Did you set the speech resource key and endpoint values?")
7172
7273
recognize_from_microphone()
7374
```

articles/ai-services/speech-service/includes/quickstarts/stt-diarization/cpp.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ Follow these steps to create a console application and install the Speech SDK.
5050

5151
int main()
5252
{
53-
// This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
53+
// This example requires environment variables named "SPEECH_KEY" and "END_POINT"
5454
auto speechKey = GetEnvironmentVariable("SPEECH_KEY");
55-
auto speechRegion = GetEnvironmentVariable("SPEECH_REGION");
55+
auto endPoint = GetEnvironmentVariable("END_POINT");
5656

57-
if ((size(speechKey) == 0) || (size(speechRegion) == 0)) {
58-
std::cout << "Please set both SPEECH_KEY and SPEECH_REGION environment variables." << std::endl;
57+
if ((size(speechKey) == 0) || (size(endPoint) == 0)) {
58+
std::cout << "Please set both SPEECH_KEY and END_POINT environment variables." << std::endl;
5959
return -1;
6060
}
6161

62-
auto speechConfig = SpeechConfig::FromSubscription(speechKey, speechRegion);
62+
auto speechConfig = SpeechConfig::FromEndpoint(speechKey, endPoint);
6363
speechConfig->SetProperty(PropertyId::SpeechServiceResponse_DiarizeIntermediateResults, "true");
6464

6565
speechConfig->SetSpeechRecognitionLanguage("en-US");
@@ -99,7 +99,7 @@ Follow these steps to create a console application and install the Speech SDK.
9999
{
100100
std::cout << "CANCELED: ErrorCode=" << (int)cancellation->ErrorCode << std::endl;
101101
std::cout << "CANCELED: ErrorDetails=" << cancellation->ErrorDetails << std::endl;
102-
std::cout << "CANCELED: Did you set the speech resource key and region values?" << std::endl;
102+
std::cout << "CANCELED: Did you set the speech resource key and endpoint values?" << std::endl;
103103
}
104104
else if (cancellation->Reason == CancellationReason::EndOfStream)
105105
{
@@ -149,7 +149,7 @@ Follow these steps to create a console application and install the Speech SDK.
149149
1. [Build and run](/cpp/build/vscpp-step-2-build) your application to start conversation transcription:
150150

151151
> [!IMPORTANT]
152-
> Make sure that you set the `SPEECH_KEY` and `SPEECH_REGION` [environment variables](#set-environment-variables). If you don't set these variables, the sample fails with an error message.
152+
> Make sure that you set the `SPEECH_KEY` and `END_POINT` [environment variables](#set-environment-variables). If you don't set these variables, the sample fails with an error message.
153153

154154
The transcribed conversation should be output as text:
155155

articles/ai-services/speech-service/includes/quickstarts/stt-diarization/csharp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ Follow these steps to create a console application and install the Speech SDK.
4949
5050
class Program
5151
{
52-
// This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
52+
// This example requires environment variables named "SPEECH_KEY" and "END_POINT"
5353
static string speechKey = Environment.GetEnvironmentVariable("SPEECH_KEY");
54-
static string speechRegion = Environment.GetEnvironmentVariable("SPEECH_REGION");
54+
static string endPoint = Environment.GetEnvironmentVariable("END_POINT");
5555
5656
async static Task Main(string[] args)
5757
{
5858
var filepath = "katiesteve.wav";
59-
var speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion);
59+
var speechConfig = SpeechConfig.FromEndpoint(speechKey, endPoint);
6060
speechConfig.SpeechRecognitionLanguage = "en-US";
6161
speechConfig.SetProperty(PropertyId.SpeechServiceResponse_DiarizeIntermediateResults, "true");
6262
@@ -95,7 +95,7 @@ Follow these steps to create a console application and install the Speech SDK.
9595
{
9696
Console.WriteLine($"CANCELED: ErrorCode={e.ErrorCode}");
9797
Console.WriteLine($"CANCELED: ErrorDetails={e.ErrorDetails}");
98-
Console.WriteLine($"CANCELED: Did you set the speech resource key and region values?");
98+
Console.WriteLine($"CANCELED: Did you set the speech resource key and endpoint values?");
9999
stopRecognition.TrySetResult(0);
100100
}
101101
@@ -133,7 +133,7 @@ Follow these steps to create a console application and install the Speech SDK.
133133
```
134134

135135
> [!IMPORTANT]
136-
> Make sure that you set the `SPEECH_KEY` and `SPEECH_REGION` [environment variables](#set-environment-variables). If you don't set these variables, the sample fails with an error message.
136+
> Make sure that you set the `SPEECH_KEY` and `END_POINT` [environment variables](#set-environment-variables). If you don't set these variables, the sample fails with an error message.
137137
138138
The transcribed conversation should be output as text:
139139

0 commit comments

Comments
 (0)