微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决将 SSML 和 Python 与 Azure 语音结合使用

我正在创建一个项目,该项目使用 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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。