Skip to content

Commit 38ea44f

Browse files
committed
env vars for clu
1 parent 379f8e1 commit 38ea44f

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed
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/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)