Skip to content

Commit b8fac43

Browse files
Merge pull request #265668 from TimShererWithAquent/us200722g
Freshness update: Azure AI Speech service
2 parents ec226c6 + 3298165 commit b8fac43

File tree

5 files changed

+69
-50
lines changed

5 files changed

+69
-50
lines changed

articles/ai-services/speech-service/includes/common/environment-variables-openai.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
author: eric-urban
33
ms.service: azure-ai-speech
44
ms.topic: include
5-
ms.date: 02/28/2023
5+
ms.date: 02/08/2024
66
ms.author: eur
77
---
88

9-
Your application must be authenticated to access Azure AI services resources. For production, use a secure way of storing and accessing your credentials. For example, after you [get a key](~/articles/ai-services/multi-service-resource.md?pivots=azportal#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.
9+
Your application must be authenticated to access Azure AI services resources. For production, use a secure way of storing and accessing your credentials. For example, after you [get a key](~/articles/ai-services/multi-service-resource.md?pivots=azportal#get-the-keys-for-your-resource) for your Speech resource, write it to a new environment variable on the local machine running the application.
1010

1111
> [!TIP]
12-
> Don't include the key directly in your code, and never post it publicly. See the Azure AI services [security](../../../security-features.md) article for more authentication options like [Azure Key Vault](../../../use-key-vault.md).
12+
> Don't include the key directly in your code, and never post it publicly. See [Azure AI services security](../../../security-features.md) for more authentication options like [Azure Key Vault](../../../use-key-vault.md).
13+
14+
To set the environment variables, open a console window, and follow the instructions for your operating system and development environment.
1315

14-
To set the environment variables, open a console window, and follow the instructions for your operating system and development environment.
1516
- To set the `OPEN_AI_KEY` environment variable, replace `your-openai-key` with one of the keys for your resource.
1617
- To set the `OPEN_AI_ENDPOINT` environment variable, replace `your-openai-endpoint` with one of the regions for your resource.
1718
- To set the `OPEN_AI_DEPLOYMENT_NAME` environment variable, replace `your-openai-deployment-name` with one of the regions for your resource.
@@ -23,15 +24,15 @@ To set the environment variables, open a console window, and follow the instruct
2324
```console
2425
setx OPEN_AI_KEY your-openai-key
2526
setx OPEN_AI_ENDPOINT your-openai-endpoint
26-
setx OPEN_AI_DEPLOYMENT_NAME=your-openai-deployment-name
27+
setx OPEN_AI_DEPLOYMENT_NAME your-openai-deployment-name
2728
setx SPEECH_KEY your-speech-key
2829
setx SPEECH_REGION your-speech-region
2930
```
3031

3132
> [!NOTE]
32-
> 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`.
33+
> If you only need to access the environment variable in the current running console, set the environment variable with `set` instead of `setx`.
3334
34-
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.
35+
After you add the environment variables, you might need to restart any running programs that need to read the environment variable, including the console window. For example, if Visual Studio is your editor, restart Visual Studio before running the example.
3536

3637
#### [Linux](#tab/linux)
3738

@@ -46,10 +47,9 @@ export SPEECH_REGION=your-speech-region
4647
After you add the environment variables, run `source ~/.bashrc` from your console window to make the changes effective.
4748

4849
#### [macOS](#tab/macos)
49-
5050
##### Bash
5151

52-
Edit your .bash_profile, and add the environment variables:
52+
Edit your *.bash_profile*, and add the environment variables:
5353

5454
```bash
5555
export OPEN_AI_KEY=your-openai-key
@@ -63,11 +63,11 @@ After you add the environment variables, run `source ~/.bash_profile` from your
6363

6464
##### Xcode
6565

66-
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.
66+
For iOS and macOS development, set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.
6767

68-
1. Select **Product** > **Scheme** > **Edit scheme**
69-
1. Select **Arguments** on the **Run** (Debug Run) page
70-
1. Under **Environment Variables** select the plus (+) sign to add a new environment variable.
68+
1. Select **Product** > **Scheme** > **Edit scheme**.
69+
1. Select **Arguments** on the **Run** (Debug Run) page.
70+
1. Under **Environment Variables** select the plus (+) sign to add a new environment variable.
7171
1. Enter `SPEECH_KEY` for the **Name** and enter your Speech resource key for the **Value**.
7272

7373
Repeat the steps to set other required environment variables.

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
author: eric-urban
33
ms.service: azure-ai-speech
44
ms.topic: include
5-
ms.date: 04/15/2022
5+
ms.date: 02/08/2024
66
ms.author: eur
77
---
88

@@ -15,6 +15,7 @@ ms.author: eur
1515
[!INCLUDE [Prerequisites](../../common/azure-prerequisites-openai.md)]
1616

1717
## Set up the environment
18+
1819
The Speech SDK is available as a [NuGet package](https://www.nuget.org/packages/Microsoft.CognitiveServices.Speech) and implements .NET Standard 2.0. You install the Speech SDK later in this guide, but first check the [SDK installation guide](../../../quickstarts/setup-platform.md?pivots=programming-language-csharp) for any more requirements.
1920

2021
### Set environment variables
@@ -27,19 +28,27 @@ This example requires environment variables named `OPEN_AI_KEY`, `OPEN_AI_ENDPOI
2728

2829
Follow these steps to create a new console application.
2930

30-
1. Open a command prompt where you want the new project, and create a console application with the .NET CLI. The `Program.cs` file should be created in the project directory.
31+
1. Open a command prompt window in the folder where you want the new project. Run this command to create a console application with the .NET CLI.
32+
3133
```dotnetcli
3234
dotnet new console
3335
```
36+
37+
The command creates a *Program.cs* file in the project directory.
38+
3439
1. Install the Speech SDK in your new project with the .NET CLI.
40+
3541
```dotnetcli
3642
dotnet add package Microsoft.CognitiveServices.Speech
3743
```
44+
3845
1. Install the Azure OpenAI SDK (prerelease) in your new project with the .NET CLI.
46+
3947
```dotnetcli
4048
dotnet add package Azure.AI.OpenAI --prerelease
4149
```
42-
1. Replace the contents of `Program.cs` with the following code.
50+
51+
1. Replace the contents of `Program.cs` with the following code.
4352
4453
```csharp
4554
using System.Text;
@@ -189,14 +198,14 @@ Follow these steps to create a new console application.
189198
190199
1. To increase or decrease the number of tokens returned by Azure OpenAI, change the `MaxTokens` property in the `ChatCompletionsOptions` class instance. For more information tokens and cost implications, see [Azure OpenAI tokens](/azure/ai-services/openai/overview#tokens) and [Azure OpenAI pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/).
191200
192-
Run your new console application to start speech recognition from a microphone:
201+
1. Run your new console application to start speech recognition from a microphone:
193202
194-
```console
195-
dotnet run
196-
```
203+
```console
204+
dotnet run
205+
```
197206
198207
> [!IMPORTANT]
199-
> Make sure that you set the `OPEN_AI_KEY`, `OPEN_AI_ENDPOINT`, `OPEN_AI_DEPLOYMENT_NAME`, `SPEECH_KEY` and `SPEECH_REGION` environment variables as described [previously](#set-environment-variables). If you don't set these variables, the sample will fail with an error message.
208+
> Make sure that you set the `OPEN_AI_KEY`, `OPEN_AI_ENDPOINT`, `OPEN_AI_DEPLOYMENT_NAME`, `SPEECH_KEY` and `SPEECH_REGION` [environment variables](#set-environment-variables) as described. If you don't set these variables, the sample will fail with an error message.
200209
201210
Speak into your microphone when prompted. The console output includes the prompt for you to begin speaking, then your request as text, and then the response from Azure OpenAI as text. The response from Azure OpenAI should be converted from text to speech and then output to the default speaker.
202211
@@ -216,12 +225,13 @@ PS C:\dev\openai\csharp>
216225
```
217226

218227
## Remarks
219-
Now that you've completed the quickstart, here are some more considerations:
220228

221-
- To change the speech recognition language, replace `en-US` with another [supported language](~/articles/ai-services/speech-service/language-support.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/ai-services/speech-service/language-identification.md).
229+
Here are some more considerations:
230+
231+
- To change the speech recognition language, replace `en-US` with another [supported language](~/articles/ai-services/speech-service/language-support.md). For example, `es-ES` for Spanish (Spain). The default language is `en-US`. For details about how to identify one of multiple languages that might be spoken, see [language identification](~/articles/ai-services/speech-service/language-identification.md).
222232
- To change the voice that you hear, replace `en-US-JennyMultilingualNeural` with another [supported voice](~/articles/ai-services/speech-service/language-support.md#prebuilt-neural-voices). If the voice doesn't speak the language of the text returned from Azure OpenAI, the Speech service doesn't output synthesized audio.
223-
- To use a different [model](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability), replace `gpt-35-turbo-instruct` with the ID of another [deployment](/azure/ai-services/openai/how-to/create-resource?pivots=web-portal#deploy-a-model). Keep in mind that the deployment ID isn't necessarily the same as the model name. You named your deployment when you created it in [Azure OpenAI Studio](https://oai.azure.com/).
224-
- Azure OpenAI 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/ai-services/openai/concepts/content-filter) article.
233+
- To use a different [model](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability), replace `gpt-35-turbo-instruct` with the ID of another [deployment](/azure/ai-services/openai/how-to/create-resource?pivots=web-portal#deploy-a-model). The deployment ID isn't necessarily the same as the model name. You named your deployment when you created it in [Azure OpenAI Studio](https://oai.azure.com/).
234+
- Azure OpenAI also performs content moderation on the prompt inputs and generated outputs. The prompts or responses might be filtered if harmful content is detected. For more information, see the [content filtering](/azure/ai-services/openai/concepts/content-filter) article.
225235

226236
## Clean up resources
227237

articles/ai-services/speech-service/includes/quickstarts/openai-speech/intro.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
author: eric-urban
33
ms.service: azure-ai-speech
44
ms.topic: include
5-
ms.date: 02/28/2023
5+
ms.date: 02/08/2024
66
ms.author: eur
77
---
88

9-
> [!IMPORTANT]
10-
> To complete the steps in this guide, access must be granted to Microsoft Azure OpenAI Service in the desired Azure subscription. Currently, access to this service is granted only by application. You can apply for access to Azure OpenAI 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 [Azure AI Speech](../../../overview.md) to converse with [Azure OpenAI Service](/azure/ai-services/openai/overview). 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.
9+
In this how-to guide, you can use Azure AI Speech to converse with Azure OpenAI Service. The text recognized by the Speech service is sent to Azure OpenAI. The Speech service synthesizes speech from the text response from Azure OpenAI.
1310

1411
Speak into the microphone to start a conversation with Azure OpenAI.
12+
1513
- The Speech service recognizes your speech and converts it into text (speech to text).
1614
- Your request as text is sent to Azure OpenAI.
17-
- The Speech service text to speech (TTS) feature synthesizes the response from Azure OpenAI to the default speaker.
15+
- The Speech service text to speech feature synthesizes the response from Azure OpenAI to the default speaker.
1816

1917
Although the experience of this example is a back-and-forth exchange, Azure OpenAI doesn't remember the context of your conversation.
18+
19+
> [!IMPORTANT]
20+
> To complete the steps in this guide, you must have access to Microsoft Azure OpenAI Service in your Azure subscription. Currently, access to this service is granted only by application. Apply for access to Azure OpenAI by completing the form at [https://aka.ms/oai/access](https://aka.ms/oai/access).

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

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
author: eric-urban
33
ms.service: azure-ai-speech
44
ms.topic: include
5-
ms.date: 03/07/2023
5+
ms.date: 02/08/2024
66
ms.author: eur
77
---
88

@@ -16,13 +16,14 @@ ms.author: eur
1616

1717
## Set up the environment
1818

19-
The Speech SDK for Python is available as a [Python Package Index (PyPI) module](https://pypi.org/project/azure-cognitiveservices-speech/). The Speech SDK for Python is compatible with Windows, Linux, and macOS.
20-
- You must install the [Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022](/cpp/windows/latest-supported-vc-redist?view=msvc-170&preserve-view=true) for your platform. Installing this package for the first time might require a restart.
19+
The Speech SDK for Python is available as a [Python Package Index (PyPI) module](https://pypi.org/project/azure-cognitiveservices-speech/). The Speech SDK for Python is compatible with Windows, Linux, and macOS.
20+
21+
- Install the [Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022](/cpp/windows/latest-supported-vc-redist?view=msvc-170&preserve-view=true) for your platform. Installing this package for the first time might require a restart.
2122
- On Linux, you must use the x64 target architecture.
2223

23-
Install a version of [Python from 3.7 or later](https://www.python.org/downloads/). First check the [SDK installation guide](../../../quickstarts/setup-platform.md?pivots=programming-language-python) for any more requirements.
24+
Install a version of [Python from 3.7 or later](https://www.python.org/downloads/). First check the [SDK installation guide](../../../quickstarts/setup-platform.md?pivots=programming-language-python) for any more requirements.
2425

25-
Install the following Python libraries: `os`, `requests`, `json`
26+
Install the following Python libraries: `os`, `requests`, `json`.
2627

2728
### Set environment variables
2829

@@ -34,19 +35,24 @@ This example requires environment variables named `OPEN_AI_KEY`, `OPEN_AI_ENDPOI
3435

3536
Follow these steps to create a new console application.
3637

37-
1. Open a command prompt where you want the new project, and create a new file named `openai-speech.py`.
38+
1. Open a command prompt window in the folder where you want the new project. Open a command prompt where you want the new project, and create a new file named `openai-speech.py`.
39+
3840
1. Run this command to install the Speech SDK:
41+
3942
```console
4043
pip install azure-cognitiveservices-speech
4144
```
45+
4246
1. Run this command to install the OpenAI SDK:
47+
4348
```console
4449
pip install openai
4550
```
51+
4652
> [!NOTE]
47-
> This library is maintained by OpenAI (not Microsoft Azure). Refer to the [release history](https://github.com/openai/openai-python/releases) or the [version.py commit history](https://github.com/openai/openai-python/commits/main/openai/version.py) to track the latest updates to the library.
53+
> This library is maintained by OpenAI, not Microsoft Azure. Refer to the [release history](https://github.com/openai/openai-python/releases) or the [version.py commit history](https://github.com/openai/openai-python/commits/main/openai/version.py) to track the latest updates to the library.
4854

49-
1. Copy the following code into `openai-speech.py`:
55+
1. Create a file named *openai-speech.py*. Copy the following code into that file:
5056

5157
```Python
5258
import os
@@ -139,11 +145,11 @@ Follow these steps to create a new console application.
139145

140146
1. To increase or decrease the number of tokens returned by Azure OpenAI, change the `max_tokens` parameter. For more information tokens and cost implications, see [Azure OpenAI tokens](/azure/ai-services/openai/overview#tokens) and [Azure OpenAI pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/).
141147

142-
Run your new console application to start speech recognition from a microphone:
148+
1. Run your new console application to start speech recognition from a microphone:
143149

144-
```console
145-
python openai-speech.py
146-
```
150+
```console
151+
python openai-speech.py
152+
```
147153

148154
> [!IMPORTANT]
149155
> Make sure that you set the `OPEN_AI_KEY`, `OPEN_AI_ENDPOINT`, `OPEN_AI_DEPLOYMENT_NAME`, `SPEECH_KEY` and `SPEECH_REGION` environment variables as described [previously](#set-environment-variables). If you don't set these variables, the sample will fail with an error message.
@@ -166,12 +172,13 @@ PS C:\dev\openai\python>
166172
```
167173

168174
## Remarks
169-
Now that you've completed the quickstart, here are some more considerations:
170175

171-
- To change the speech recognition language, replace `en-US` with another [supported language](~/articles/ai-services/speech-service/language-support.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/ai-services/speech-service/language-identification.md).
176+
Here are some more considerations:
177+
178+
- To change the speech recognition language, replace `en-US` with another [supported language](~/articles/ai-services/speech-service/language-support.md). For example, `es-ES` for Spanish (Spain). The default language is `en-US`. For details about how to identify one of multiple languages that might be spoken, see [language identification](~/articles/ai-services/speech-service/language-identification.md).
172179
- To change the voice that you hear, replace `en-US-JennyMultilingualNeural` with another [supported voice](~/articles/ai-services/speech-service/language-support.md#prebuilt-neural-voices). If the voice doesn't speak the language of the text returned from Azure OpenAI, the Speech service doesn't output synthesized audio.
173180
- To use a different [model](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability), replace `gpt-35-turbo-instruct` with the ID of another [deployment](/azure/ai-services/openai/how-to/create-resource#deploy-a-model). Keep in mind that the deployment ID isn't necessarily the same as the model name. You named your deployment when you created it in [Azure OpenAI Studio](https://oai.azure.com/).
174-
- Azure OpenAI 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/ai-services/openai/concepts/content-filter) article.
181+
- Azure OpenAI also performs content moderation on the prompt inputs and generated outputs. The prompts or responses might be filtered if harmful content is detected. For more information, see the [content filtering](/azure/ai-services/openai/concepts/content-filter) article.
175182

176183
## Clean up resources
177184

0 commit comments

Comments
 (0)