【问题标题】:How to modify cognitive services TTS example to play the audio synthesized如何修改认知服务 TTS 示例以播放合成的音频
【发布时间】:2017-01-16 06:02:38
【问题描述】:

我正在使用here 提供的 TTS 的 python 示例,它似乎一切正常:

$ 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

但是,我的期望是直接从我的计算机上听到翻译后的文本,但这并没有发生。我是否遗漏了任何步骤?

我需要做什么才能听到合成文本的声音版本?我正在使用 Mac。

【问题讨论】:

    标签: speech-recognition text-to-speech bing-api microsoft-cognitive


    【解决方案1】:

    你可以使用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()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-31
      • 2015-04-07
      • 1970-01-01
      • 2018-02-06
      • 2019-11-17
      • 1970-01-01
      • 2021-02-19
      相关资源
      最近更新 更多