Skip to content

Commit 82b5982

Browse files
committed
openai env vars etc
1 parent 0014203 commit 82b5982

File tree

5 files changed

+87
-10
lines changed

5 files changed

+87
-10
lines changed

articles/cognitive-services/Speech-Service/includes/common/environment-variables-clu.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ author: eric-urban
33
ms.service: cognitive-services
44
ms.subservice: speech-service
55
ms.topic: include
6-
ms.date: 09/14/2022
6+
ms.date: 02/28/2023
77
ms.author: eur
88
---
99

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: 02/28/2023
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 `OPEN_AI_KEY` environment variable, replace `your-openai-key` with one of the keys for your resource.
17+
- To set the `OPEN_AI_ENDPOINT` environment variable, replace `your-openai-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 OPEN_AI_KEY your-openai-key
25+
setx OPEN_AI_ENDPOINT your-openai-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 OPEN_AI_KEY=your-openai-key
39+
export OPEN_AI_ENDPOINT=your-openai-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 OPEN_AI_KEY=your-openai-key
54+
export OPEN_AI_ENDPOINT=your-openai-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/openai-speech/intro.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ ms.date: 02/28/2023
66
ms.author: eur
77
---
88

9-
You can run this Python script to converse with Azure OpenAI. Although the experience is a back-and-forth exchange, Azure OpenAI doesn't remember the context of your conversation.
9+
> [!IMPORTANT]
10+
> To complete the steps in this guide, access must be granted to the Azure OpenAI service in the desired Azure subscription. Currently, access to this service is granted only by application. You can apply for access to the Azure OpenAI service by completing the form at [https://aka.ms/oai/access](https://aka.ms/oai/access).
11+
12+
In this how-to guide, you can use Speech to converse with Azure OpenAI. The text recognized by the Speech service is sent to Azure OpenAI. The text response from Azure OpenAI is then synthesized by the Speech service.
1013

11-
Speak into the microphone to start a conversation with OpenAI.
14+
Speak into the microphone to start a conversation with Azure OpenAI.
1215
- Azure Cognitive Services Speech recognizes your speech and converts it into text (speech-to-text).
1316
- Your request as text is sent to the Azure OpenAI service.
1417
- Azure Cognitive Services Speech synthesizes (text-to-speech) the response from Azure OpenAI to the default speaker.
1518

16-
> [!IMPORTANT]
17-
> To complete the steps in this guide, access must be granted to the Azure OpenAI service in the desired Azure subscription. Currently, access to this service is granted only by application. You can apply for access to the Azure OpenAI service by completing the form at [https://aka.ms/oai/access](https://aka.ms/oai/access). Open an issue on this repo to contact us if you have an issue.
19+
Although the experience of this example is a back-and-forth exchange, Azure OpenAI doesn't remember the context of your conversation.

articles/cognitive-services/Speech-Service/includes/quickstarts/openai-speech/python.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Install the following Python libraries: `os`, `requests`, `json`
2626

2727
### Set environment variables
2828

29+
This example requires environment variables named `OPEN_AI_KEY`, `OPEN_AI_ENDPOINT`, `SPEECH_KEY`, and `SPEECH_REGION`.
30+
2931
[!INCLUDE [Environment variables](../../common/environment-variables.md)]
3032

3133
## Recognize speech from a microphone
@@ -157,6 +159,7 @@ Now that you've completed the quickstart, here are some additional consideration
157159

158160
- To change the speech recognition language, replace `en-US` with another [supported language](~/articles/cognitive-services/speech-service/supported-languages.md). For example, `es-ES` for Spanish (Spain). The default language is `en-US` if you don't specify a language. For details about how to identify one of multiple languages that might be spoken, see [language identification](~/articles/cognitive-services/speech-service/language-identification.md).
159161
- To change the voice that you hear, replace `en-US-JennyMultilingualNeural` with another [supported voice](~/articles/cognitive-services/speech-service/supported-languages.md#prebuilt-neural-voices). If the voice does not speak the language of the text returned from Azure OpenAI, the Speech service won't output synthesized audio.
162+
- To use a different [deployed](/azure/cognitive-services/openai/how-to/create-resource#deploy-a-model) Azure OpenAI model, replace `text-davinci-002` with another [model](/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability). For example, `text-davinci-003` for the latest version of the Davinci model.
160163
- The Azure OpenAI Service also performs content moderation on the prompt inputs and generated outputs. The prompts or responses may be filtered if harmful content is detected. For more information, see the [content filtering](/azure/cognitive-services/openai/concepts/content-filter) article.
161164

162165
## Clean up resources

articles/cognitive-services/Speech-Service/openai-speech.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: "Azure OpenAI speech to speech chat - Speech service"
33
titleSuffix: Azure Cognitive Services
4-
description: In this how-to guide, you can use Speech to converse with OpenAI. Although the experience is a back-and-forth exchange, OpenAI doesn't remember the context of your conversation.
4+
description: In this how-to guide, you can use Speech to converse with Azure OpenAI. The text recognized by the Speech service is sent to Azure OpenAI. The text response from Azure OpenAI is then synthesized by the Speech service.
55
services: cognitive-services
66
author: eric-urban
77
manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: speech-service
1010
ms.topic: how-to
11-
ms.date: 02/23/2023
11+
ms.date: 02/28/2023
1212
ms.author: eur
1313
ms.devlang: python
1414
keywords: speech to text, openai
@@ -22,6 +22,5 @@ keywords: speech to text, openai
2222

2323
## Next steps
2424

25-
> [!div class="nextstepaction"]
26-
> [Learn more about Speech](overview.md)
27-
> [Learn more about Azure OpenAI](/azure/cognitive-services/openai/overview)
25+
- [Learn more about Speech](overview.md)
26+
- [Learn more about Azure OpenAI](/azure/cognitive-services/openai/overview)

0 commit comments

Comments
 (0)