cdxyh
deepin
2020-04-28 15:39 config={
'appId':'*********',
'apiKey':'************',
'secretKey':'*************'}
里面的***部分是百度账号的信息,隐藏了!
'appId':'*********',
'apiKey':'************',
'secretKey':'*************'}
里面的***部分是百度账号的信息,隐藏了!
Reply Like 0 View the author


中文 


底下是源码,请不吝指教!
from aip import AipSpeech
import os
import sys
import json
config={
'appId':'*********',
'apiKey':'************',
'secretKey':'*************'
}
client = AipSpeech(**config)
text=""
file=sys.argv[1]
def tts(text):
result = client.synthesis(text, 'zh', 1, { "spd":5, 'pit':5, 'vol': 5, 'per':1, }) # 识别正确返回语音二进制 错误则返回dict 参照下面错误码
if not isinstance(result, dict):
with open("temp.mp3", 'wb') as f:
f.write(result)
f.close()
os.system("play temp.mp3")
tts(text)
def main():
a = open(file, 'r')
while True:
text = a.readline()
tts(text)
main()