松岗做网站哪家便宜,如何建立一个微信公众号平台,新东方一对一辅导价格,wordpress裁剪失败最近要做一些普通话和方言demo
找一个免费工具
免费在线文字转语音工具 | edge-tts 在线体验 (bingal.com) 还有一些方言在阿里云上找了下#xff0c;基于官方demo改了一下
阿里云语音合成接口说明_智能语音交互(ISI)-阿里云帮助中心 (aliyun.com)
如何下载安装、使用语音…
最近要做一些普通话和方言demo
找一个免费工具
免费在线文字转语音工具 | edge-tts 在线体验 (bingal.com) 还有一些方言在阿里云上找了下基于官方demo改了一下
阿里云语音合成接口说明_智能语音交互(ISI)-阿里云帮助中心 (aliyun.com)
如何下载安装、使用语音合成PythonSDK及代码示例_智能语音交互(ISI)-阿里云帮助中心 (aliyun.com)
# -*- coding: UTF-8 -*-import time
import threading
import sysimport nlsURLwss://nls-gateway-cn-shanghai.aliyuncs.com/ws/v1
TOKENxxx #参考https://help.aliyun.com/document_detail/450255.html获取token
APPKEYxxx #获取Appkey请前往控制台https://nls-portal.console.aliyun.com/applistTEXT[这是第一条测试语料请欣赏,这是第二条测试语料请欣赏]#以下代码会根据上述TEXT文本反复进行语音合成
class TestTts:def __init__(self, tid, test_file):self.__th threading.Thread(targetself.__test_run)self.__id tidself.__test_file test_filedef start(self, text):self.__text textself.__f open(self.__test_file, wb)self.__th.start()def test_on_metainfo(self, message, *args):print(on_metainfo message{}.format(message)) def test_on_error(self, message, *args):print(on_error args{}.format(args))def test_on_close(self, *args):print(on_close: args{}.format(args))try:self.__f.close()except Exception as e:print(close file failed since:, e)def test_on_data(self, data, *args):try:self.__f.write(data)except Exception as e:print(write data failed:, e)def test_on_completed(self, message, *args):print(on_completed:args{} message{}.format(args, message))def __test_run(self):print(thread:{} start...format(self.__id))tts nls.NlsSpeechSynthesizer(urlURL,tokenTOKEN,appkeyAPPKEY,on_metainfoself.test_on_metainfo,on_dataself.test_on_data,on_completedself.test_on_completed,on_errorself.test_on_error,on_closeself.test_on_close,callback_args[self.__id])print({}: session start.format(self.__id))r tts.start(self.__text, voicecuijie, aformatmp3,speech_rate-250)print({}: tts done with result:{}.format(self.__id, r))def multiruntest(num):for i in range(0, num):name thread str(i)t TestTts(name, tests/output_ttsstr(i).mp3)t.start(TEXT[i])nls.enableTrace(True)
multiruntest(2)