Skip to content

Commit 2f8b9e5

Browse files
Merge pull request #229015 from eric-urban/eur/speech-updates
correct links
2 parents e071d90 + 38ea44f commit 2f8b9e5

File tree

5 files changed

+87
-29
lines changed

5 files changed

+87
-29
lines changed

articles/cognitive-services/Speech-Service/includes/common/azure-prerequisites-clu.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.author: eur
99

1010
> [!div class="checklist"]
1111
> * Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services)
12-
> * [Create a Language resource](https://portal.azure.com/#create/Microsoft.CognitiveServicesTextAnalytics)Create a Language resource</a> in the Azure portal.
12+
> * [Create a Language resource](https://portal.azure.com/#create/Microsoft.CognitiveServicesTextAnalytics) in the Azure portal.
1313
> * Get the Language resource key and endpoint. After your Language resource is deployed, select **Go to resource** to view and manage keys. For more information about Cognitive Services resources, see [Get the keys for your resource](~/articles/cognitive-services/cognitive-services-apis-create-account.md#get-the-keys-for-your-resource).
1414
> * [Create a Speech resource](https://portal.azure.com/#create/Microsoft.CognitiveServicesSpeechServices) in the Azure portal.
1515
> * Get the Speech resource key and region. After your Speech resource is deployed, select **Go to resource** to view and manage keys. For more information about Cognitive Services resources, see [Get the keys for your resource](~/articles/cognitive-services/cognitive-services-apis-create-account.md#get-the-keys-for-your-resource).
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
author: eric-urban
3+
ms.service: cognitive-services
4+
ms.subservice: speech-service
5+
ms.topic: include
6+
ms.date: 09/14/2022
7+
ms.author: eur
8+
---
9+
10+
Your application must be authenticated to access Cognitive Services resources. For production, use a secure way of storing and accessing your credentials. For example, after you [get a key](~/articles/cognitive-services/cognitive-services-apis-create-account.md#get-the-keys-for-your-resource) for your <a href="https://portal.azure.com/#create/Microsoft.CognitiveServicesSpeechServices" title="Create a Speech resource" target="_blank">Speech resource</a>, write it to a new environment variable on the local machine running the application.
11+
12+
> [!TIP]
13+
> Don't include the key directly in your code, and never post it publicly. See the Cognitive Services [security](../../../security-features.md) article for more authentication options like [Azure Key Vault](../../../use-key-vault.md).
14+
15+
To set the environment variables, open a console window, and follow the instructions for your operating system and development environment.
16+
- To set the `LANGUAGE_KEY` environment variable, replace `your-language-key` with one of the keys for your resource.
17+
- To set the `LANGUAGE_ENDPOINT` environment variable, replace `your-language-endpoint` with one of the regions for your resource.
18+
- To set the `SPEECH_KEY` environment variable, replace `your-speech-key` with one of the keys for your resource.
19+
- To set the `SPEECH_REGION` environment variable, replace `your-speech-region` with one of the regions for your resource.
20+
21+
#### [Windows](#tab/windows)
22+
23+
```console
24+
setx LANGUAGE_KEY your-language-key
25+
setx LANGUAGE_ENDPOINT your-language-endpoint
26+
setx SPEECH_KEY your-speech-key
27+
setx SPEECH_REGION your-speech-region
28+
```
29+
30+
> [!NOTE]
31+
> If you only need to access the environment variable in the current running console, you can set the environment variable with `set` instead of `setx`.
32+
33+
After you add the environment variables, you may need to restart any running programs that will need to read the environment variable, including the console window. For example, if you are using Visual Studio as your editor, restart Visual Studio before running the example.
34+
35+
#### [Linux](#tab/linux)
36+
37+
```bash
38+
export LANGUAGE_KEY=your-language-key
39+
export LANGUAGE_ENDPOINT=your-language-endpoint
40+
export SPEECH_KEY=your-speech-key
41+
export SPEECH_REGION=your-speech-region
42+
```
43+
44+
After you add the environment variables, run `source ~/.bashrc` from your console window to make the changes effective.
45+
46+
#### [macOS](#tab/macos)
47+
48+
##### Bash
49+
50+
Edit your .bash_profile, and add the environment variables:
51+
52+
```bash
53+
export LANGUAGE_KEY=your-language-key
54+
export LANGUAGE_ENDPOINT=your-language-endpoint
55+
export SPEECH_KEY=your-speech-key
56+
export SPEECH_REGION=your-speech-region
57+
```
58+
59+
After you add the environment variables, run `source ~/.bash_profile` from your console window to make the changes effective.
60+
61+
##### Xcode
62+
63+
For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.
64+
65+
1. Select **Product** > **Scheme** > **Edit scheme**
66+
1. Select **Arguments** on the **Run** (Debug Run) page
67+
1. Under **Environment Variables** select the plus (+) sign to add a new environment variable.
68+
1. Enter `SPEECH_KEY` for the **Name** and enter your Speech resource key for the **Value**.
69+
70+
Repeat the steps to set other required environment variables.
71+
72+
For more configuration options, see the [Xcode documentation](https://help.apple.com/xcode/#/dev745c5c974).
73+
***

articles/cognitive-services/Speech-Service/includes/how-to/compressed-audio-input/java.md

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
author: eric-urban
33
ms.service: cognitive-services
44
ms.topic: include
5-
ms.date: 03/11/2020
5+
ms.date: 02/28/2023
66
ms.custom: devx-track-java
77
ms.author: eur
88
---
@@ -35,32 +35,13 @@ Choose a platform for installation instructions.
3535

3636
## Example
3737

38-
To configure the Speech SDK to accept compressed audio input, create a `PullAudioInputStream` or `PushAudioInputStream`. Then, create an `AudioConfig` from an instance of your stream class that specifies the compression format of the stream. Find related sample code in [Speech SDK samples](https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/java/jre/console/src/com/microsoft/cognitiveservices/speech/samples/console/WavStream.java).
38+
To configure the Speech SDK to accept compressed audio input, create a `PullAudioInputStream` or `PushAudioInputStream`. Then, create an `AudioConfig` from an instance of your stream class that specifies the compression format of the stream. Find related sample code in [Speech SDK samples](https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/java/android/compressed-input/app/src/main/java/com/microsoft/cognitiveservices/speech/samples/compressedinput/MainActivity.java).
3939

40-
Let's assume that you have an input stream class called `pullStream` and are using OPUS/OGG. Your code might look like this:
40+
Let's assume that you have an input stream class called `pullAudio` and are using MP3. Your code might look like this:
4141

4242
```java
43-
import com.microsoft.cognitiveservices.speech.audio.AudioConfig;
44-
import com.microsoft.cognitiveservices.speech.audio.AudioInputStream;
45-
import com.microsoft.cognitiveservices.speech.audio.AudioStreamFormat;
46-
import com.microsoft.cognitiveservices.speech.audio.PullAudioInputStream;
47-
import com.microsoft.cognitiveservices.speech.audio.AudioStreamContainerFormat;
48-
49-
// ... omitted for brevity
50-
51-
SpeechConfig speechConfig =
52-
SpeechConfig.fromSubscription(
53-
"YourSubscriptionKey",
54-
"YourServiceRegion");
55-
56-
// Create an audio config specifying the compressed
57-
// audio format and the instance of your input stream class.
58-
PullAudioInputStream pullStream = AudioInputStream.createPullStream(
59-
AudioStreamFormat.getCompressedFormat(AudioStreamContainerFormat.OGG_OPUS));
60-
AudioConfig audioConfig = AudioConfig.fromStreamInput(pullStream);
61-
62-
SpeechRecognizer recognizer = new SpeechRecognizer(speechConfig, audioConfig);
63-
SpeechRecognitionResult result = recognizer.recognizeOnceAsync().get();
64-
65-
String text = result.getText();
43+
String filePath = "whatstheweatherlike.mp3";
44+
PullAudioInputStream pullAudio = AudioInputStream.createPullStream(new BinaryAudioStreamReader(filePath),
45+
AudioStreamFormat.getCompressedFormat(AudioStreamContainerFormat.MP3));
46+
AudioConfig audioConfig = AudioConfig.fromStreamInput(pullAudio);
6647
```

articles/cognitive-services/Speech-Service/includes/quickstarts/intent-recognition-clu/cpp.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ The Speech SDK is available as a [NuGet package](https://www.nuget.org/packages/
2020

2121
### Set environment variables
2222

23-
[!INCLUDE [Environment variables](../../common/environment-variables.md)]
23+
This example requires environment variables named `LANGUAGE_KEY`, `LANGUAGE_ENDPOINT`, `SPEECH_KEY`, and `SPEECH_REGION`.
24+
25+
[!INCLUDE [Environment variables](../../common/environment-variables-clu.md)]
2426

2527
## Create a Conversational Language Understanding project
2628

articles/cognitive-services/Speech-Service/includes/quickstarts/intent-recognition-clu/csharp.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ The Speech SDK is available as a [NuGet package](https://www.nuget.org/packages/
2020

2121
### Set environment variables
2222

23-
[!INCLUDE [Environment variables](../../common/environment-variables.md)]
23+
This example requires environment variables named `LANGUAGE_KEY`, `LANGUAGE_ENDPOINT`, `SPEECH_KEY`, and `SPEECH_REGION`.
24+
25+
[!INCLUDE [Environment variables](../../common/environment-variables-clu.md)]
2426

2527
## Create a Conversational Language Understanding project
2628

0 commit comments

Comments
 (0)