Skip to content

Commit 43cdb4c

Browse files
authored
Merge pull request #108438 from IEvangelist/fixPythonBits
Fix python quick start code
2 parents 669c8fe + b7767fe commit 43cdb4c

File tree

2 files changed

+30
-35
lines changed
  • articles/cognitive-services/Speech-Service/includes/quickstarts

2 files changed

+30
-35
lines changed

articles/cognitive-services/Speech-Service/includes/quickstarts/from-file/python/python.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
author: IEvangelist
33
ms.service: cognitive-services
44
ms.topic: include
5-
ms.date: 03/10/2020
5+
ms.date: 03/20/2020
66
ms.author: dapine
77
---
88

@@ -31,7 +31,7 @@ If you have a problem, or you're missing a feature, see [Support and help option
3131

3232
You can copy the [sample code](#sample-code) from this quickstart to a source file `quickstart.py` and run it in your IDE or in the console:
3333

34-
```sh
34+
```Bash
3535
python quickstart.py
3636
```
3737

@@ -53,7 +53,7 @@ speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_r
5353
# Creates an audio configuration that points to an audio file.
5454
# Replace with your own audio filename.
5555
audio_filename = "whatstheweatherlike.wav"
56-
audio_input = speechsdk.AudioConfig(filename=audio_filename)
56+
audio_input = speechsdk.audio.AudioConfig(filename=audio_filename)
5757

5858
# Creates a recognizer with the given settings
5959
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_input)

articles/cognitive-services/Speech-Service/includes/quickstarts/tts-audio-file/python/python.md

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
---
2-
title: 'Quickstart: Synthesize speech into audio file, Python - Speech service'
3-
titleSuffix: Azure Cognitive Services
4-
description: TBD
5-
services: cognitive-services
6-
author: chlandsi
7-
manager: nitinme
2+
author: IEvangelist
83
ms.service: cognitive-services
9-
ms.subservice: speech-service
104
ms.topic: include
11-
ms.date: 07/05/2019
12-
ms.author: chlandsi
5+
ms.date: 03/20/2020
6+
ms.author: dapine
137
---
148

159
## Prerequisites
@@ -22,30 +16,32 @@ ms.author: chlandsi
2216
* Linux: Ubuntu 16.04, Ubuntu 18.04, Debian 9, RHEL 8, CentOS 8 on x64.
2317
* On Linux, run these commands to install the required packages:
2418

25-
* On Ubuntu:
19+
# [Ubuntu](#tab/ubuntu)
2620

27-
```sh
28-
sudo apt-get update
29-
sudo apt-get install build-essential libssl1.0.0 libasound2
30-
```
21+
```Bash
22+
sudo apt-get update
23+
sudo apt-get install build-essential libssl1.0.0 libasound2
24+
```
3125

32-
* On Debian 9:
26+
# [Debian 9](#tab/debian)
3327

34-
```sh
35-
sudo apt-get update
36-
sudo apt-get install build-essential libssl1.0.2 libasound2
37-
```
28+
```Bash
29+
sudo apt-get update
30+
sudo apt-get install build-essential libssl1.0.2 libasound2
31+
```
3832

39-
* On RHEL/CentOS 8:
33+
# [RHEL / CentOS 8](#tab/rhel-centos)
4034

41-
```sh
42-
sudo yum update
43-
sudo yum install alsa-lib openssl python3
44-
```
35+
```Bash
36+
sudo yum update
37+
sudo yum install alsa-lib openssl python3
38+
```
4539

4640
> [!NOTE]
4741
> On RHEL/CentOS 8, follow the instructions on [how to configure OpenSSL for Linux](~/articles/cognitive-services/speech-service/how-to-configure-openssl-linux.md).
4842
43+
---
44+
4945
* On Windows, you need the [Microsoft Visual C++ Redistributable for Visual Studio 2019](https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads) for your platform.
5046

5147
## Install the Speech SDK
@@ -54,7 +50,7 @@ ms.author: chlandsi
5450

5551
This command installs the Python package from [PyPI](https://pypi.org/) for the Speech SDK:
5652

57-
```sh
53+
```Bash
5854
pip install azure-cognitiveservices-speech
5955
```
6056

@@ -72,16 +68,15 @@ If you have a problem, or you're missing a feature, see [Support and help option
7268

7369
You can copy the [sample code](#sample-code) from this quickstart to a source file `quickstart.py` and run it in your IDE or in the console:
7470

75-
```sh
71+
```Bash
7672
python quickstart.py
7773
```
7874

7975
Or you can download this quickstart tutorial as a [Jupyter](https://jupyter.org) notebook from the [Speech SDK sample repository](https://github.com/Azure-Samples/cognitive-services-speech-sdk/) and run it as a notebook.
8076

8177
### Sample code
8278

83-
````Python
84-
79+
````python
8580
import azure.cognitiveservices.speech as speechsdk
8681

8782
# Replace with your own subscription key and region identifier from here: https://aka.ms/speech/sdkregion
@@ -91,7 +86,7 @@ speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_r
9186
# Creates an audio configuration that points to an audio file.
9287
# Replace with your own audio filename.
9388
audio_filename = "helloworld.wav"
94-
audio_output = speechsdk.AudioOutputConfig(filename=audio_filename)
89+
audio_output = speechsdk.audio.AudioOutputConfig(filename=audio_filename)
9590

9691
# Creates a synthesizer with the given settings
9792
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=audio_output)
@@ -133,14 +128,14 @@ elif result.reason == speechsdk.ResultReason.Canceled:
133128
1. Copy, paste, and save the [Python code](#sample-code) to the newly created file.
134129
1. Insert your Speech service subscription information.
135130
1. If selected, a Python interpreter displays on the left side of the status bar at the bottom of the window.
136-
Otherwise, bring up a list of available Python interpreters. Open the command palette (Ctrl+Shift+P) and enter **Python: Select Interpreter**. Choose an appropriate one.
131+
Otherwise, bring up a list of available Python interpreters. Open the command palette (<kbd>Ctrl+Shift+P</kbd>) and enter **Python: Select Interpreter**. Choose an appropriate one.
137132
1. You can install the Speech SDK Python package from within Visual Studio Code. Do that if it's not installed yet for the Python interpreter you selected.
138-
To install the Speech SDK package, open a terminal. Bring up the command palette again (Ctrl+Shift+P) and enter **Terminal: Create New Integrated Terminal**.
133+
To install the Speech SDK package, open a terminal. Bring up the command palette again (<kbd>Ctrl+Shift+P</kbd>) and enter **Terminal: Create New Integrated Terminal**.
139134
In the terminal that opens, enter the command `python -m pip install azure-cognitiveservices-speech` or the appropriate command for your system.
140135
1. To run the sample code, right-click somewhere inside the editor. Select **Run Python File in Terminal**.
141136
Your text is converted to speech, and saved in the audio data specified.
142137

143-
```text
138+
```console
144139
Speech synthesized to [helloworld.wav] for text [Hello world!]
145140
```
146141

0 commit comments

Comments
 (0)