azure 将文本语言更改为语音

jhiyze9q  于 2023-02-16  发布在  其他
关注(0)|答案(1)|浏览(169)

我想把 Azure 的声音从Python,用这些特点

languageCode = 'es‑MX'
ssmlGender = 'FEMALE' 
voicName = 'es‑MX‑DaliaNeural'

但是我是Azure的新手,所以我不知道怎么做,这是我的代码:

import PyPDF2
import azure.cognitiveservices.speech as sdk

key = "fake key"
region = "fake region"

config = sdk.SpeechConfig(subscription=key, region=region)
synthesizer = sdk.SpeechSynthesizer(speech_config=config)

book = open("prueba.pdf", "rb")
reader = PyPDF2.PdfFileReader(book)

for num in range(0,reader.numPages):
    text = reader.getPage(num).extractText()

result = synthesizer.speak_text_async(text).get()
qij5mzcb

qij5mzcb1#

根据文档https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/how-to-speech-synthesis?tabs=browserjs%2Cterminal&pivots=programming-language-python#select-synthesis-language-and-voice,您应该能够:

config.speech_synthesis_language = "es‑MX" 
config.speech_synthesis_voice_name ="es-MX-DaliaNeural"

声音列表在这里https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/language-support?tabs=tts

相关问题