如何修改认知服务TTS示例来播放合成的音频
How to modify cognitive services TTS example to play the audio synthesized
我正在使用 here 提供的 python TTS 示例,它似乎工作正常:
$ python3 python_projects/TTSSample.py
Connect to server to get the Access Token
200 OK
Access Token: eyJ0eXAiOiJKV1QiLCJhMiOiJ1cm46bXMuY29nbml0[truncated]
Connect to server to synthesize the wave
200 OK
The synthesized wave length: 9040
然而,我的期望是听到翻译后的文本直接从我的计算机上说出来,但这不是 happening.Am 我是否遗漏了任何步骤?
我需要做什么才能听到合成文本的有声版本?我正在使用 Mac。
可以使用Pyaudio库,需要先安装,然后
data = response.read()
conn.close()
print("The synthesized wave length: %d" %(len(data)))
import pyaudio
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16,
channels=1,
rate=16000,
output=True)
stream.write(data)
stream.close()
我正在使用 here 提供的 python TTS 示例,它似乎工作正常:
$ python3 python_projects/TTSSample.py
Connect to server to get the Access Token
200 OK
Access Token: eyJ0eXAiOiJKV1QiLCJhMiOiJ1cm46bXMuY29nbml0[truncated]
Connect to server to synthesize the wave
200 OK
The synthesized wave length: 9040
然而,我的期望是听到翻译后的文本直接从我的计算机上说出来,但这不是 happening.Am 我是否遗漏了任何步骤?
我需要做什么才能听到合成文本的有声版本?我正在使用 Mac。
可以使用Pyaudio库,需要先安装,然后
data = response.read()
conn.close()
print("The synthesized wave length: %d" %(len(data)))
import pyaudio
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16,
channels=1,
rate=16000,
output=True)
stream.write(data)
stream.close()