快速入门:安装开发环境Quickstart: Setup development environment
选择目标环境Choose your target environment
重要
需要语音 SDK 版本 1.11.0 或更高版本。Speech SDK version 1.11.0 or later is required.
本指南介绍如何安装用于 .NET Framework (Windows) 的语音 SDK。This guide shows how to install the Speech SDK for .NET Framework (Windows). 如果只是需要包名称以便自行开始,请在 NuGet 控制台中运行 Install-Package Microsoft.CognitiveServices.Speech
。If you just want the package name to get started on your own, run Install-Package Microsoft.CognitiveServices.Speech
in the NuGet console.
重要
下载任何 Azure 认知服务语音 SDK,即表示你已确认接受其许可条款。By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. 有关详细信息,请参阅:For more information, see:
先决条件Prerequisites
本快速入门需要:This quickstart requires:
- Visual Studio 2019Visual Studio 2019
- 需要语音 SDK 版本 1.11.0 或更高版本。Speech SDK version 1.11.0 or later is required.
创建 Visual Studio 项目并安装语音 SDKCreate a Visual Studio project and install the Speech SDK
需安装语音 SDK NuGet 包,以便在代码中引用它。You'll need to install the Speech SDK NuGet package so you can reference it in your code. 为此,可能首先需要创建 helloworld 项目。To do that, you may first need to create a helloworld project. 如果已经有一个可以使用“.NET 桌面开发”工作负荷的项目,则可使用该项目并跳到使用 NuGet 包管理器安装语音 SDK。If you already have a project with the .NET desktop development workload available, you can use that project and skip to Use NuGet Package Manager to install the Speech SDK.
创建 helloworld 项目Create helloworld project
打开 Visual Studio 2019。Open Visual Studio 2019.
在“开始”窗口中,选择“创建新项目”。In the Start window, select Create a new project.
在“创建新项目”窗口中,选择“控制台应用(.NET Framework)”,然后选择“下一步”。 In the Create a new project window, choose Console App (.NET Framework), and then select Next.
在“配置新项目”窗口中的“项目名称”内输入 helloworld,在“位置”中选择或创建目录路径,然后选择“创建”。 In the Configure your new project window, enter helloworld in Project name, choose or create the directory path in Location, and then select Create.
在 Visual Studio 菜单栏中,选择“工具” > “获取工具和功能”打开 Visual Studio 安装程序并显示“修改”对话框。 From the Visual Studio menu bar, select Tools > Get Tools and Features, which opens Visual Studio Installer and displays the Modifying dialog box.
检查“.NET 桌面开发”工作负荷是否可用。Check whether the .NET desktop development workload is available. 如果尚未安装该工作负荷,请选中它旁边的复选框,然后选择“修改”以启动安装。If the workload hasn't been installed, select the check box next to it, and then select Modify to start the installation. 下载和安装过程可能需要几分钟。It may take a few minutes to download and install.
如果已选中“.NET 桌面开发”旁边的复选框,请选择“关闭”退出对话框。 If the check box next to .NET desktop development is already selected, select Close to exit the dialog box.
关闭 Visual Studio 安装程序。Close Visual Studio Installer.
使用 NuGet 包管理器安装语音 SDKUse NuGet Package Manager to install the Speech SDK
在解决方案资源管理器中右键单击“helloworld”项目,然后选择“管理 NuGet 包”显示 NuGet 包管理器。 In the Solution Explorer, right-click the helloworld project, and then select Manage NuGet Packages to show the NuGet Package Manager.
在右上角找到“包源”下拉框,确保选择了
nuget.org
。In the upper-right corner, find the Package Source drop-down box, and make sure thatnuget.org
is selected.在左上角,选择“浏览”。In the upper-left corner, select Browse.
在搜索框中,键入 Microsoft.CognitiveServices.Speech 并按 Enter。In the search box, type Microsoft.CognitiveServices.Speech and select Enter.
在搜索结果中选择“Microsoft.CognitiveServices.Speech”包,然后选择“安装”以安装最新稳定版本。 From the search results, select the Microsoft.CognitiveServices.Speech package, and then select Install to install the latest stable version.
接受所有协议和许可证,开始安装。Accept all agreements and licenses to start the installation.
安装此包后,“包管理器控制台”窗口中将显示一条确认消息。After the package is installed, a confirmation appears in the Package Manager Console window.
选择目标体系结构Choose target architecture
若要生成并运行控制台应用程序,请创建与计算机体系结构匹配的平台配置。To build and run the console application, create a platform configuration matching your computer's architecture.
在菜单栏中,选择“生成” > “配置管理器” 。From the menu bar, select Build > Configuration Manager. 此时将显示“配置管理器”对话框。The Configuration Manager dialog box appears.
在“活动解决方案平台”下拉框中,选择“新建” 。In the Active solution platform drop-down box, select New. 此时将显示“新建解决方案平台”对话框。The New Solution Platform dialog box appears.
在“键入或选择新平台”下拉框中:In the Type or select the new platform drop-down box:
- 如果运行的是 64 位 Windows,请选择 x64。If you're running 64-bit Windows, select x64.
- 如果运行的是 32 位 Windows,请选择 x86。If you're running 32-bit Windows, select x86.
选择“确定”,然后选择“关闭”。 Select OK and then Close.
后续步骤Next steps
- 快速入门:识别来自麦克风的语音Quickstart: Recognize speech from a microphone
- 快速入门:从文件中识别语音Quickstart: Recognize speech from a file
- 快速入门:识别来自 Azure Blob 的语音Quickstart: Recognize speech from an Azure Blob
- 快速入门:将语音转换为文本Quickstart: Translate speech-to-text
- 快速入门:将文本合成到音频设备Quickstart: Synthesize text to an audio device
- 快速入门:将文本合成到文件Quickstart: Synthesize text to a file
- 快速入门:识别意向Quickstart: Recognize Intents
选择目标环境Choose your target environment
本指南介绍如何安装用于 Linux 的语音 SDKThis guide shows how to install the Speech SDK for Linux
重要
下载任何 Azure 认知服务语音 SDK,即表示你已确认接受其许可条款。By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. 有关详细信息,请参阅:For more information, see:
系统要求System requirements
Linux(Ubuntu 16.04、Ubuntu 18.04、Debian 9、RHEL 7/8、CentOS 7/8)Linux (Ubuntu 16.04, Ubuntu 18.04, Debian 9, RHEL 7/8, CentOS 7/8)
先决条件Prerequisites
若要完成本快速入门,你需要:To complete this quickstart, you'll need:
支持的 Linux 平台会要求安装某些库(要求安装
libssl
以获取安全套接字层支持;要求安装libasound2
以获取声音支持)。Supported Linux platforms will require certain libraries installed (libssl
for secure sockets layer support andlibasound2
for sound support). 请参阅下面的发行版,了解安装这些库的正确版本所需的命令。Refer to your distribution below for the commands needed to install the correct versions of these libraries.在 Ubuntu 上:On Ubuntu:
sudo apt-get update sudo apt-get install build-essential libssl1.0.0 libasound2 wget
在 Debian 9 上:On Debian 9:
sudo apt-get update sudo apt-get install build-essential libssl1.0.2 libasound2 wget
在 RHEL/CentOS 上:On RHEL/CentOS:
sudo yum update sudo yum groupinstall "Development tools" sudo yum install alsa-lib openssl wget
备注
- 在 RHEL/CentOS 7 上,按照如何为语音 SDK 配置 RHEL/CentOS 7 上的说明进行操作。On RHEL/CentOS 7, follow the instructions on how to configure RHEL/CentOS 7 for Speech SDK.
- 在 RHEL/CentOS 8 上,按照如何配置 OpenSSL for Linux 上的说明进行操作。On RHEL/CentOS 8, follow the instructions on how to configure OpenSSL for Linux.
安装语音 SDKInstall Speech SDK
适用于 Linux 的语音 SDK 可用于构建 64 位和 32 位应用程序。The Speech SDK for Linux can be used to build both 64-bit and 32-bit applications. 可以从 https://aka.ms/csspeech/linuxbinary 以 tar 文件格式下载必需的库和头文件。The required libraries and header files can be downloaded as a tar file from https://aka.ms/csspeech/linuxbinary.
下载并安装 SDK,如下所示:Download and install the SDK as follows:
选择应将语音 SDK 文件提取到的目录,然后将
SPEECHSDK_ROOT
环境变量设置为指向该目录。Choose a directory to which the Speech SDK files should be extracted, and set theSPEECHSDK_ROOT
environment variable to point to that directory. 使用此变量,在将来的命令中可以轻松引用目录。This variable makes it easy to refer to the directory in future commands. 例如,如果要使用主目录中的speechsdk
目录,请使用如下所示的命令:For example, if you want to use the directoryspeechsdk
in your home directory, use a command like the following:export SPEECHSDK_ROOT="$HOME/speechsdk"
如果该目录尚不存在,请创建该目录。Create the directory if it doesn't exist yet.
mkdir -p "$SPEECHSDK_ROOT"
下载并提取包含语音 SDK 二进制文件的
.tar.gz
存档:Download and extract the.tar.gz
archive containing the Speech SDK binaries:wget -O SpeechSDK-Linux.tar.gz https://aka.ms/csspeech/linuxbinary tar --strip 1 -xzf SpeechSDK-Linux.tar.gz -C "$SPEECHSDK_ROOT"
验证所提取的程序包的顶级目录的内容:Validate the contents of the top-level directory of the extracted package:
ls -l "$SPEECHSDK_ROOT"
目录列表应当包含第三方通告和许可证文件,以及一个包含头文件 (
.h
) 的include
目录和一个包含库的lib
目录。The directory listing should contain the third-party notice and license files, as well as aninclude
directory containing header (.h
) files and alib
directory containing libraries.路径Path 说明Description license.md
许可License ThirdPartyNotices.md
第三方声明。Third-party notices. REDIST.txt
再分发声明。Redistribution notice. include
C 和 C++ 必需的头文件The required header files for C and C++ lib/x64
x64 必需的用来链接应用程序的本机库Native library for x64 required to link your application lib/x86
x86 必需的用来链接应用程序的本机库Native library for x86 required to link your application
后续步骤Next steps
- 快速入门:识别来自麦克风的语音Quickstart: Recognize speech from a microphone
- 快速入门:从文件中识别语音Quickstart: Recognize speech from a file
- 快速入门:识别来自 Azure Blob 的语音Quickstart: Recognize speech from an Azure Blob
- 快速入门:将语音转换为文本Quickstart: Translate speech-to-text
- 快速入门:将文本合成到音频设备Quickstart: Synthesize text to an audio device
- 快速入门:将文本合成到文件Quickstart: Synthesize text to a file
- 快速入门:识别意向Quickstart: Recognize Intents
选择目标环境Choose your target environment
本指南介绍如何安装用于 64 位 Java 8 JRE 的语音 SDK。This guide shows how to install the Speech SDK for 64-bit Java 8 JRE. 如果只是需要包名称以便自行开始,那么请知悉在 Maven 中央存储库中未提供 Java SDK。If you just want the package name to get started on your own, the Java SDK is not available in the Maven central repository. 无论是使用 Gradle 还是 pom.xml
依赖项文件,都需要添加指向 https://csspeechstorage.blob.core.windows.net/maven/
的自定义存储库(请参阅下文了解包名称)。Whether you're using Gradle or a pom.xml
dependency file, you need to add a custom repository pointing to https://csspeechstorage.blob.core.windows.net/maven/
(see below for package name).
备注
对于语音设备 SDK 和 Roobo 设备,请参阅语音设备 SDK。For the Speech Devices SDK and the Roobo device, see Speech Devices SDK.
重要
下载任何 Azure 认知服务语音 SDK,即表示你已确认接受其许可条款。By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. 有关详细信息,请参阅:For more information, see:
支持的操作系统Supported operating systems
- Java 语音 SDK 包适用于以下操作系统:The Java Speech SDK package is available for these operating systems:
- Windows:仅 64 位Windows: 64-bit only
- Mac:macOS X 10.13 或更高版本Mac: macOS X version 10.13 or later
- Linux:仅 64 位的 Ubuntu 16.04、Ubuntu 18.04、Debian 9、RHEL 7/8、CentOS 7/8Linux: 64-bit only on Ubuntu 16.04, Ubuntu 18.04, Debian 9, RHEL 7/8, CentOS 7/8
先决条件Prerequisites
Eclipse Java IDE(要求已安装 Java)Eclipse Java IDE (requires Java already installed)
需要语音 SDK 版本 1.11.0 或更高版本。Speech SDK version 1.11.0 or later is required.
支持的 Linux 平台会要求安装某些库(要求安装
libssl
以获取安全套接字层支持;要求安装libasound2
以获取声音支持)。Supported Linux platforms will require certain libraries installed (libssl
for secure sockets layer support andlibasound2
for sound support). 请参阅下面的发行版,了解安装这些库的正确版本所需的命令。Refer to your distribution below for the commands needed to install the correct versions of these libraries.在 Ubuntu 上,请运行以下命令来安装所需的包:On Ubuntu, run the following commands to install the required packages:
sudo apt-get update sudo apt-get install build-essential libssl1.0.0 libasound2
在 Debian 9 上,请运行以下命令来安装所需的包:On Debian 9, run the following commands to install the required packages:
sudo apt-get update sudo apt-get install build-essential libssl1.0.2 libasound2
在 RHEL/CentOS 上,请运行以下命令来安装所需的包:On RHEL/CentOS, run the following commands to install the required packages:
sudo yum update sudo yum install alsa-lib java-1.8.0-openjdk-devel openssl
备注
- 在 RHEL/CentOS 7 上,按照如何为语音 SDK 配置 RHEL/CentOS 7 上的说明进行操作。On RHEL/CentOS 7, follow the instructions on how to configure RHEL/CentOS 7 for Speech SDK.
- 在 RHEL/CentOS 8 上,按照如何配置 OpenSSL for Linux 上的说明进行操作。On RHEL/CentOS 8, follow the instructions on how to configure OpenSSL for Linux.
- 在 Windows 上,需要安装适用于平台的 Microsoft Visual C++ Redistributable for Visual Studio 2019。On Windows, you need the Microsoft Visual C++ Redistributable for Visual Studio 2019 for your platform. 请注意,首次安装它时,可能需要重启 Windows 才能继续使用本指南。Note that installing this for the first time may require you to restart Windows before continuing with this guide.
创建 Eclipse 项目并安装语音 SDKCreate an Eclipse project and install the Speech SDK
启动 Eclipse。Start Eclipse.
在 Eclipse Launcher 中,在“工作区”字段中输入某个新工作区目录的名称。In the Eclipse Launcher, in the Workspace field, enter the name of a new workspace directory. 然后选择“启动”。Then select Launch.
片刻之后,Eclipse IDE 的主窗口将会显示。In a moment, the main window of the Eclipse IDE appears. 关闭欢迎屏幕(如果存在)。Close the Welcome screen if one is present.
从 Eclipse 菜单栏上,通过选择“文件” > “新建” > “项目”创建一个新项目。From the Eclipse menu bar, create a new project by choosing File > New > Project.
将显示“新建项目”对话框。The New Project dialog box appears. 选择“Java 项目”,然后选择“下一步”。Select Java Project, and select Next.
此时将启动“新建 Java 项目”向导。The New Java Project wizard starts. 在“项目名称”字段中,输入 quickstart,然后选择 JavaSE 1.8 作为执行环境。In the Project name field, enter quickstart, and choose JavaSE-1.8 as the execution environment. 选择“完成”。Select Finish.
如果出现了“打开关联的透视图?”窗口,请选择“打开透视图”。If the Open Associated Perspective? window appears, select Open Perspective.
在包资源管理器中,右键单击 quickstart 项目。In the Package explorer, right-click the quickstart project. 从上下文菜单中选择“配置” > “转换为 Maven 项目”。Choose Configure > Convert to Maven Project from the context menu.
此时将显示“新建 POM”窗口。The Create new POM window appears. 在“组 ID”字段中输入 com.microsoft.cognitiveservices.speech.samples,然后在“项目 ID”字段中输入 quickstart。In the Group Id field, enter com.microsoft.cognitiveservices.speech.samples, and in the Artifact Id field, enter quickstart. 然后选择“完成”。Then select Finish.
打开 pom.xml 文件并对其进行编辑。Open the pom.xml file and edit it.
- 在文件末尾,在结束标记
</project>
前面,创建一个repositories
元素,使其中包含对语音 SDK 的 Maven 存储库的引用,如下所示:At the end of the file, before the closing tag</project>
, create arepositories
element with a reference to the Maven repository for the Speech SDK, as shown here:
<repositories> <repository> <id>maven-cognitiveservices-speech</id> <name>Microsoft Cognitive Services Speech Maven Repository</name> <url>https://csspeechstorage.blob.core.windows.net/maven/</url> </repository> </repositories>
- 此外,还添加一个
dependencies
元素(使用语音 SDK 版本 1.13.0 作为依赖项):Also add adependencies
element, with the Speech SDK version 1.13.0 as a dependency:
<dependencies> <dependency> <groupId>com.microsoft.cognitiveservices.speech</groupId> <artifactId>client-sdk</artifactId> <version>1.7.0</version> </dependency> </dependencies>
- 保存更改。Save the changes.
- 在文件末尾,在结束标记
后续步骤Next steps
- 快速入门:识别来自麦克风的语音Quickstart: Recognize speech from a microphone
- 快速入门:从文件中识别语音Quickstart: Recognize speech from a file
- 快速入门:识别来自 Azure Blob 的语音Quickstart: Recognize speech from an Azure Blob
- 快速入门:将语音转换为文本Quickstart: Translate speech-to-text
- 快速入门:将文本合成到音频设备Quickstart: Synthesize text to an audio device
- 快速入门:将文本合成到文件Quickstart: Synthesize text to a file
- 快速入门:识别意向Quickstart: Recognize Intents
本指南介绍如何安装用于 Python 的语音 SDK。This guide shows how to install the Speech SDK for Python. 如果只是需要包名称以便自行开始,请运行 pip install azure-cognitiveservices-speech
。If you just want the package name to get started on your own, run pip install azure-cognitiveservices-speech
.
重要
下载任何 Azure 认知服务语音 SDK,即表示你已确认接受其许可条款。By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. 有关详细信息,请参阅:For more information, see:
支持的操作系统Supported operating systems
- Python 语音 SDK 包适用于以下操作系统:The Python Speech SDK package is available for these operating systems:
- Windows:x64 和 x86Windows: x64 and x86
- Mac:macOS X 10.12 或更高版本Mac: macOS X version 10.12 or later
- Linux:请参阅受支持的 Linux 分发和目标体系结构的列表。Linux; see the list of supported Linux distributions and target architectures.
先决条件Prerequisites
需要语音 SDK 版本 1.11.0 或更高版本。Speech SDK version 1.11.0 or later is required.
支持的 Linux 平台会要求安装某些库(要求安装
libssl
以获取安全套接字层支持;要求安装libasound2
以获取声音支持)。Supported Linux platforms will require certain libraries installed (libssl
for secure sockets layer support andlibasound2
for sound support). 请参阅下面的发行版,了解安装这些库的正确版本所需的命令。Refer to your distribution below for the commands needed to install the correct versions of these libraries.在 Ubuntu/Debian 上,请运行以下命令来安装所需的包:On Ubuntu/Debian, run the following commands to install the required packages:
sudo apt-get update sudo apt-get install build-essential libssl1.0.0 libasound2
如果 libssl1.0.0 不可用,则改为安装 libssl1.0.x(其中 x 大于 0)或 libssl1.1。If libssl1.0.0 is not available, install libssl1.0.x (where x is greater than 0) or libssl1.1 instead.
在 RHEL/CentOS 上,请运行以下命令来安装所需的包:On RHEL/CentOS, run the following commands to install the required packages:
sudo yum update sudo yum install alsa-lib openssl python3
备注
- 在 RHEL/CentOS 7 上,按照如何为语音 SDK 配置 RHEL/CentOS 7 上的说明进行操作。On RHEL/CentOS 7, follow the instructions on how to configure RHEL/CentOS 7 for Speech SDK.
- 在 RHEL/CentOS 8 上,按照如何配置 OpenSSL for Linux 上的说明进行操作。On RHEL/CentOS 8, follow the instructions on how to configure OpenSSL for Linux.
- 在 Windows 上,需要安装适用于平台的 Microsoft Visual C++ Redistributable for Visual Studio 2019。On Windows, you need the Microsoft Visual C++ Redistributable for Visual Studio 2019 for your platform. 请注意,首次安装它时,可能需要重启 Windows 才能继续使用本指南。Note that installing this for the first time may require you to restart Windows before continuing with this guide.
- 最后,需要 Python 3.5 到 3.8。And finally, you'll need Python 3.5 to 3.8. 若要检查安装,请打开命令提示符并键入命令
python --version
,然后检查结果。To check your installation, open a command prompt and type the commandpython --version
and check the result. 如果安装正确,将会收到“Python 3.5.1”或类似的响应。If it's installed properly, you'll get a response "Python 3.5.1" or similar.
从 PyPI 安装语音 SDKInstall the Speech SDK from PyPI
如果使用自己的环境或生成工具,请运行以下命令,从 PyPI 安装语音 SDK。If you're using your own environment or build tools, run the following command to install the Speech SDK from PyPI. 对于 Visual Studio Code 的用户,请跳到下一子部分以按照指导安装。For users of Visual Studio Code, skip to the next sub-section for guided installation.
pip install azure-cognitiveservices-speech
如果在 macOS 上操作,可能需要运行以下命令才能让上述 pip
命令正常运行:If you are on macOS, you may need to run the following command to get the pip
command above to work:
python3 -m pip install --upgrade pip
成功使用 pip
安装 azure-cognitiveservices-speech
后,可以通过将命名空间导入 Python 项目来使用语音 SDK。Once you've successfully used pip
to install azure-cognitiveservices-speech
, you can use the Speech SDK by importing the namespace into your Python projects.
import azure.cognitiveservices.speech as speechsdk
使用 Visual Studio Code 安装语音 SDKInstall the Speech SDK using Visual Studio Code
下载并安装适用于你的平台的最新受支持 Python 版本(3.5 到 3.8)。Download and install the latest supported version of Python for your platform, 3.5 to 3.8.
- 在安装过程中,Windows 用户必须选择“将 Python 添加到 PATH”。Windows users make sure to select "Add Python to your PATH" during the installation process.
下载并安装 Visual Studio Code。Download and install Visual Studio Code.
打开 Visual Studio Code 并安装 Python 扩展。Open Visual Studio Code and install the Python extension. 在菜单中选择“文件” > “首选项” > “扩展”。Select File > Preferences > Extensions from the menu. 搜索 Python 并单击“安装”。Search for Python and click Install.
同样在 Visual Studio Code 中,通过集成式命令行安装语音 SDK Python 包:Also from within Visual Studio Code, install the Speech SDK Python package from the integrated command line:
- 打开终端(在下拉菜单中选择“终端” > “新终端”) Open a terminal (from the drop-down menus, Terminal > New Terminal)
- 在打开的终端中输入命令
python -m pip install azure-cognitiveservices-speech
In the terminal that opens, enter the commandpython -m pip install azure-cognitiveservices-speech
如果你不熟悉 Visual Studio Code,请参阅更详细的 Visual Studio Code 文档。If you are new to Visual Studio Code, refer to the more extensive Visual Studio Code Documentation. 有关 Visual Studio Code 和 Python 的详细信息,请参阅 Visual Studio Code Python 教程。For more information about Visual Studio Code and Python, see Visual Studio Code Python tutorial.
支持和更新Support and updates
语音 SDK Python 包的更新将通过 PyPI 分发,发行说明中会发布相关通告。Updates to the Speech SDK Python package are distributed via PyPI and announced in the Release notes.
如果有新版本可用,可以使用 pip install --upgrade azure-cognitiveservices-speech
命令进行更新。If a new version is available, you can update to it with the command pip install --upgrade azure-cognitiveservices-speech
.
通过查看 azure.cognitiveservices.speech.__version__
变量来检查当前安装的版本。Check which version is currently installed by inspecting the azure.cognitiveservices.speech.__version__
variable.
如果遇到问题或者缺少某项功能,请查看支持和帮助选项。If you have a problem, or you're missing a feature, see Support and help options.
后续步骤Next steps
- 快速入门:识别来自麦克风的语音Quickstart: Recognize speech from a microphone
- 快速入门:从文件中识别语音Quickstart: Recognize speech from a file
- 快速入门:识别来自 Azure Blob 的语音Quickstart: Recognize speech from an Azure Blob
- 快速入门:将语音转换为文本Quickstart: Translate speech-to-text
- 快速入门:将文本合成到音频设备Quickstart: Synthesize text to an audio device
- 快速入门:将文本合成到文件Quickstart: Synthesize text to a file
- 快速入门:识别意向Quickstart: Recognize Intents
本指南介绍如何安装用于 Linux 的语音 SDKThis guide shows how to install the Speech SDK for Linux
重要
下载任何 Azure 认知服务语音 SDK,即表示你已确认接受其许可条款。By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. 有关详细信息,请参阅:For more information, see:
系统要求System requirements
Linux:请参阅受支持的 Linux 分发和目标体系结构的列表。Linux; see the list of supported Linux distributions and target architectures.
先决条件Prerequisites
若要完成本快速入门,你需要:To complete this quickstart, you'll need:
gccgcc
支持的 Linux 平台会要求安装某些库(要求安装
libssl
以获取安全套接字层支持;要求安装libasound2
以获取声音支持)。Supported Linux platforms will require certain libraries installed (libssl
for secure sockets layer support andlibasound2
for sound support). 请参阅下面的发行版,了解安装这些库的正确版本所需的命令。Refer to your distribution below for the commands needed to install the correct versions of these libraries.在 Ubuntu/Debian 上:On Ubuntu/Debian:
sudo apt-get update sudo apt-get install build-essential libssl1.0.0 libasound2 wget
如果 libssl1.0.0 不可用,则改为安装 libssl1.0.x(其中 x 大于 0)或 libssl1.1。If libssl1.0.0 is not available, install libssl1.0.x (where x is greater than 0) or libssl1.1 instead.
在 RHEL/CentOS 上:On RHEL/CentOS:
sudo yum update sudo yum groupinstall "Development tools" sudo yum install alsa-lib openssl wget
备注
- 在 RHEL/CentOS 7 上,按照如何为语音 SDK 配置 RHEL/CentOS 7 上的说明进行操作。On RHEL/CentOS 7, follow the instructions on how to configure RHEL/CentOS 7 for Speech SDK.
- 在 RHEL/CentOS 8 上,按照如何配置 OpenSSL for Linux 上的说明进行操作。On RHEL/CentOS 8, follow the instructions on how to configure OpenSSL for Linux.
安装语音 SDKInstall Speech SDK
适用于 Linux 的语音 SDK 可用于构建 64 位和 32 位应用程序。The Speech SDK for Linux can be used to build both 64-bit and 32-bit applications. 可以从 https://aka.ms/csspeech/linuxbinary 以 tar 文件格式下载必需的库和头文件。The required libraries and header files can be downloaded as a tar file from https://aka.ms/csspeech/linuxbinary.
下载并安装 SDK,如下所示:Download and install the SDK as follows:
选择应将语音 SDK 文件提取到的目录,然后将
SPEECHSDK_ROOT
环境变量设置为指向该目录。Choose a directory to which the Speech SDK files should be extracted, and set theSPEECHSDK_ROOT
environment variable to point to that directory. 使用此变量,在将来的命令中可以轻松引用目录。This variable makes it easy to refer to the directory in future commands. 例如,如果要使用主目录中的speechsdk
目录,请使用如下所示的命令:For example, if you want to use the directoryspeechsdk
in your home directory, use a command like the following:export SPEECHSDK_ROOT="$HOME/speechsdk"
如果该目录尚不存在,请创建该目录。Create the directory if it doesn't exist yet.
mkdir -p "$SPEECHSDK_ROOT"
下载并提取包含语音 SDK 二进制文件的
.tar.gz
存档:Download and extract the.tar.gz
archive containing the Speech SDK binaries:wget -O SpeechSDK-Linux.tar.gz https://aka.ms/csspeech/linuxbinary tar --strip 1 -xzf SpeechSDK-Linux.tar.gz -C "$SPEECHSDK_ROOT"
验证所提取的程序包的顶级目录的内容:Validate the contents of the top-level directory of the extracted package:
ls -l "$SPEECHSDK_ROOT"
目录列表应当包含第三方通告和许可证文件,以及一个包含头文件 (
.h
) 的include
目录和一个包含库的lib
目录。The directory listing should contain the third-party notice and license files, as well as aninclude
directory containing header (.h
) files and alib
directory containing libraries.路径Path 说明Description license.md
许可License ThirdPartyNotices.md
第三方声明。Third-party notices. REDIST.txt
再分发声明。Redistribution notice. include
C 和 C++ 必需的头文件The required header files for C and C++ lib/x64
x64 必需的用来链接应用程序的本机库Native library for x64 required to link your application lib/x86
x86 必需的用来链接应用程序的本机库Native library for x86 required to link your application
配置 Go 环境Configure Go environment
执行以下步骤,设置 Go 环境,以查找语音 SDK。Perform the following steps to set up your Go environment to find the Speech SDK. 在两个步骤中,将 <architecture>
替换为 CPU 的处理器体系结构。In both steps, replace <architecture>
with the processor architecture of your CPU. 即为 x86
、x64
、arm32
或 arm64
。This will be x86
, x64
, arm32
, or arm64
.
由于绑定依赖于
cgo
,因此需要设置环境变量,以便 Go 可以找到 SDK:Since the bindings rely oncgo
, you need to set the environment variables so Go can find the SDK:export CGO_CFLAGS="-I$SPEECHSDK_ROOT/include/c_api" export CGO_LDFLAGS="-L$SPEECHSDK_ROOT/lib/<architecture> -lMicrosoft.CognitiveServices.Speech.core"
为了运行包含 SDK 的应用程序,我们需要告诉 OS 在哪里可以找到这些库:To run applications including the SDK, we need to tell the OS where to find the libs:
export LD_LIBRARY_PATH="$SPEECHSDK_ROOT/lib/<architecture>:$LD_LIBRARY_PATH"
后续步骤Next steps
- 快速入门:识别来自麦克风的语音Quickstart: Recognize speech from a microphone
- 快速入门:从文件中识别语音Quickstart: Recognize speech from a file
选择目标环境Choose your target environment
本指南介绍如何安装可以在网页中使用的 JavaScript 版语音 SDK。This guide shows how to install the Speech SDK for JavaScript for use with a web page.
重要
下载任何 Azure 认知服务语音 SDK,即表示你已确认接受其许可条款。By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. 有关详细信息,请参阅:For more information, see:
新建网站文件夹Create a new Website folder
新建空文件夹。Create a new, empty folder. 如果要在 web 服务器上承载示例,请确保 web 服务器可访问文件夹。In case you want to host the sample on a web server, make sure that the web server can access the folder.
将 JavaScript 的语音 SDK 解压缩到文件夹Unpack the Speech SDK for JavaScript into that folder
将语音 SDK 作为 .zip 包下载,并将其解压缩到新建文件夹。Download the Speech SDK as a .zip package and unpack it into the newly created folder. 这会导致以下五个文件被解压缩:This results in five files being unpacked:
microsoft.cognitiveservices.speech.sdk.bundle.js
人工可读的语音 SDK 版本。microsoft.cognitiveservices.speech.sdk.bundle.js
A human readable version of the Speech SDK.microsoft.cognitiveservices.speech.sdk.bundle.js.map
用于调试 SDK 代码的映射文件。microsoft.cognitiveservices.speech.sdk.bundle.js.map
A map file used for debugging SDK code.microsoft.cognitiveservices.speech.sdk.bundle.d.ts
用于 TypeScript 的对象定义microsoft.cognitiveservices.speech.sdk.bundle.d.ts
Object definitions for use with TypeScriptmicrosoft.cognitiveservices.speech.sdk.bundle-min.js
语音 SDK 的简化版。microsoft.cognitiveservices.speech.sdk.bundle-min.js
A minified version of the Speech SDK.speech-processor.js
用于提高某些浏览器性能的代码。speech-processor.js
Code to improve performance on some browsers.
创建 index.html 页面Create an index.html page
在文件夹中创建名为 index.html
的新文件,使用文本编辑器打开此文件。Create a new file in the folder, named index.html
and open this file with a text editor.
后续步骤Next steps
- 快速入门:识别来自麦克风的语音Quickstart: Recognize speech from a microphone
- 快速入门:从文件中识别语音Quickstart: Recognize speech from a file
- 快速入门:识别来自 Azure Blob 的语音Quickstart: Recognize speech from an Azure Blob
- 快速入门:将语音转换为文本Quickstart: Translate speech-to-text
- 快速入门:将文本合成到音频设备Quickstart: Synthesize text to an audio device
- 快速入门:将文本合成到文件Quickstart: Synthesize text to a file
- 快速入门:识别意向Quickstart: Recognize Intents