python - 将 SSML 和 Python 与 Azure 语音结合使用

标签 python azure text-to-speech azure-cognitive-services ssml

我正在创建一个项目,该项目使用 Azure 的语音转文本功能向用户朗读字符串。我想用 SSML 更改语音性别和风格,但 Python 似乎并没有真正支持字符串中所需的所有符号。我找不到任何相关文档,但是有办法吗?

我的代码:

import azure.cognitiveservices.speech as speechsdk


what_needs_to_be_spoken = "Sample text to be spoken"

# Creates an instance of a speech config with specified subscription key and service region.
# Replace with your own subscription key and service region (e.g., "westus").
speech_key, service_region = "insert_azure_speech_key_here", "eastus"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)


# Creates a speech synthesizer using the default speaker as audio output.
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)

# Synthesizes the received text to speech.
# The synthesized speech is expected to be heard on the speaker with this line executed.
result = speech_synthesizer.speak_text_async(what_needs_to_be_spoken).get()

最佳答案

SpeechSynthesizer 的 SDK 完全支持 SSML

Python 应该支持字符串内所需的所有符号。

这里是 python 中字符串的总体概述。

https://realpython.com/python-strings/#string-manipulation

如果您需要更多,请告诉我们。

关于python - 将 SSML 和 Python 与 Azure 语音结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68379509/

相关文章:

python - Python os.system 出现问题

azure - 从 Azure 云服务客户端连接到 OpenVPN 服务器

javascript - 使用多个变量打开不同的链接

sql - Azure 单一数据库与弹性池数据库

azure - 使用 "jwks_uri"端点中的值验证从 azure ad b2c 接收的 token

python - 如何在 python 中将文本转换为语音(mp3 文件)?

swift - AVFoundation 类未在 OSX xcode 项目中解析

Python 2.X 在字符串周围添加单引号

python - 将 Matlab hist() 与 Numpy histogram() 匹配

python - 包括项目中的库。最佳实践