开发者社区> 问答> 正文

语音合成python SDK执行时无法生成wav文件

win10环境下下载python sdk并配置完服务端需要的设置,初次运行的时候在命令行执行python tests/test_tts/py 文件, 生成了test_tts.pcm 文件且输出信息如下

thread:thread0 start..
thread0: session start
2022-05-12 10:22:17,902 - DEBUG - callback args:[]
2022-05-12 10:22:18,038 - DEBUG - get token 28843902abe946b486d0039e5e5b1ac2
2022-05-12 10:22:18,039 - DEBUG - ws run...
2022-05-12 10:22:18,039 - DEBUG - wait cond wakeup
2022-05-12 10:22:18,152 - DEBUG - core_on_open:(<nls._core.NlsCore object at 0x000002130F03CCD0>, '{"header": {"message_id": "cd6a7d2a6d3941bdae56d4030c3e6605", "task_id": "1cb0c2a08e5148ea862bdc67103ca047", "namespace": "SpeechSynthesizer", "name": "StartSynthesis", "appkey": "rBjTtVQwMUzU7pjD"}, "payload": {"text": "\\u5927\\u58ee\\u6b63\\u60f3\\u53bb\\u6458\\u53d6\\u82b1\\u74e3\\uff0c\\u8c01\\u77e5\\u963f\\u4e3d\\u548c\\u963f\\u5f3a\\u7a81\\u7136\\u5185\\u8ba7\\uff0c\\u963f\\u4e3d\\u62ff\\u53bb\\u624b\\u67aa\\u5411\\u6811\\u5e72\\u8fb9\\u7684\\u963f\\u5f3a\\u5c04\\u51fb\\uff0c\\u4e24\\u58f0\\u67aa\\u54cd\\uff0c\\u963f\\u5f3a\\u76f4\\u63a5\\u5012\\u5165\\u6c34\\u4e2d", "voice": "ailun", "format": "pcm", "sample_rate": 16000, "volume": 50, "speech_rate": 0, "pitch_rate": 0}}')
2022-05-12 10:22:20,535 - DEBUG - core_on_msg:{"header":{"namespace":"SpeechSynthesizer","name":"SynthesisCompleted","status":20000000,"message_id":"43cd7a65da94408db1d203b2eacd0765","task_id":"1cb0c2a08e5148ea862bdc67103ca047","status_text":"Gateway:SUCCESS:Success."}}
2022-05-12 10:22:20,536 - DEBUG - __syn_core_on_msg:msg={"header":{"namespace":"SpeechSynthesizer","name":"SynthesisCompleted","status":20000000,"message_id":"43cd7a65da94408db1d203b2eacd0765","task_id":"1cb0c2a08e5148ea862bdc67103ca047","status_text":"Gateway:SUCCESS:Success."}} args=()
2022-05-12 10:22:20,536 - DEBUG - __handle_message
2022-05-12 10:22:20,536 - DEBUG - __synthesis_completed
2022-05-12 10:22:20,559 - DEBUG - __synthesis_completed shutdown done
on_completed:args=>('thread0',) message=>{"header":{"namespace":"SpeechSynthesizer","name":"SynthesisCompleted","status":20000000,"message_id":"43cd7a65da94408db1d203b2eacd0765","task_id":"1cb0c2a08e5148ea862bdc67103ca047","status_text":"Gateway:SUCCESS:Success."}}
2022-05-12 10:22:20,560 - DEBUG - core_on_close
thread0: tts done with result:True
2022-05-12 10:22:20,560 - DEBUG - __sr_core_on_close
on_close: args=>('thread0',)
2022-05-12 10:22:20,561 - DEBUG - ws exit...

通过对比文档已知此次执行结果为正常,但疑问如下

  1. 合成数据被写成了pcm文件,如何将文件类型改写输出为wav。尝试修改test_tts.py内的语句
t = TestTts(name, "tests/test_tts.pcm")

,但改变后缀名的方法无效 。尝试修改nls/ _speech_synthesizer.py 内的

def start(self, text="", voice="xiaoyun", aformat="pcm",

类型为wav,同样无效 2. 执行语句后线程一直处于循环执行,虽然通过修改while语句的值可以终止执行。但想了解如何通过控制线程来终止线程执行

展开
收起
游客xdaumztxpljnw 2022-05-12 14:51:31 759 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载