神经语音不起作用 pt-BR-FranciscaNeural



我正在为ENDPOINT使用API:https://brazilsouth.api.cognitive.microsoft.com/sts/v1.0/issuetoken我试图在这个网站上实现一个教程:https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-text-to-speech但我不能让它工作。当我得到一个列表时,Voices不会显示pt BR FranciscaNeural,但在文档中,它说语音是可用的。

import requests
import time
from xml.etree import ElementTree
try:
input = input
except NameError:
pass
class TextToSpeech(object):
def __init__(self, subscription_key):
self.subscription_key = subscription_key
self.tts = input("What would you like to convert to speech: ")
self.timestr = time.strftime("%Y%m%d-%H%M")
self.access_token = None

def get_token(self):
fetch_token_url = "https://brazilsouth.api.cognitive.microsoft.com/sts/v1.0/issueToken"
headers = {
'Ocp-Apim-Subscription-Key': self.subscription_key
}
response = requests.post(fetch_token_url, headers=headers)
self.access_token = str(response.text)

def save_audio(self):
base_url = 'https://brazilsouth.tts.speech.microsoft.com/'
path = 'cognitiveservices/v1'
constructed_url = base_url + path
headers = {
'Authorization': 'Bearer ' + self.access_token,
'Content-Type': 'application/ssml+xml',
'X-Microsoft-OutputFormat': 'riff-24khz-16bit-mono-pcm',
'User-Agent': 'YOUR_RESOURCE_NAME'
}
xml_body = ElementTree.Element('speak', version='1.0')
xml_body.set('{http://www.w3.org/XML/1998/namespace}lang', 'pt-br')
voice = ElementTree.SubElement(xml_body, 'voice')
voice.set('{http://www.w3.org/XML/1998/namespace}lang', 'pt-BR')
voice.set(
'name', 'Microsoft Server Speech Text to Speech Voice (pt-BR, FranciscaNeural)')
voice.text = self.tts

body = ElementTree.tostring(xml_body)
response = requests.post(constructed_url, headers=headers, data=body)
if response.status_code == 200:
with open('sample-' + self.timestr + '.wav', 'wb') as audio:
audio.write(response.content)
print("nStatus code: " + str(response.status_code) +
"nYour TTS is ready for playback.n")
else:
print("nStatus code: " + str(response.status_code) +
"nSomething went wrong. Check your subscription key and headers.n")
if __name__ == "__main__":
subscription_key = "put-here-a-keycode"
app = TextToSpeech(subscription_key)
app.get_token()
app.save_audio()

我解决了这个问题,我改变了服务器的位置,因为我发现我使用的不符合神经语言。

我设法使用另一台服务器:使用方济各的语音

fetch_token_url="https://eastus.api.cognitive.microsoft.com/sts/v1.0/issueToken"

它运行得很好

请参阅此线程:https://github.com/MicrosoftDocs/azure-docs/issues/52032

根据线程,有一个已知的问题正在积极解决,pt BR FranciscaNeural已被有意删除,直到修复为止。

相关内容

  • 没有找到相关文章

最新更新