我运行一个烧瓶服务器,只要页面上发生特定操作,就会调用该函数:
def generate_audio(text, target):
# create the path
tmp_dir = os.path.join(os.getcwd(), "app/data/audio")
if not os.path.exists(tmp_dir):
os.mkdir(tmp_dir)
path = os.path.join(tmp_dir, f'{target}-{text}.wav')
# query the API
speech_config = SpeechConfig(
subscription=cfg['speech']['key'], region=cfg['speech']['location'])
audio_config = AudioOutputConfig(filename=path)
synthesizer = SpeechSynthesizer(
speech_config=speech_config, audio_config=audio_config)
synthesizer.speak_text("A simple test")
在执行结束时,包含音频的文件只是一个空的 0B 文件。我从字面上复制粘贴了快速入门指南,所以我不知道出了什么问题。
我所做的尝试是将订阅密钥更改为随机的,并且没有引发错误。在 azure 服务网页的日志中也没有出现任何内容。
这是取消的详细信息
SpeechSynthesisCancellationDetails(reason=CancellationReason.Error, error_details="Connection failed (no connection to the remote host). Internal error: 11. Error details: Code: 0. USP state: 2. Received audio size: 0 bytes.")
这是日志