2.0 KiB
2.0 KiB
In [ ]:
#gTTS语音
from gtts import gTTS
#engine = pyttsx3.init('espeak')
tts = gTTS(text="军士上前,将英玉兰架起,两个抓着脚踝,两个托住肩头,一起用力,英玉兰无奈分开两条大浪腿,露出骚屄,被举下",lang='zh-cn')
#engine.save_to_file("欢迎使用百度语音合成,本次测试为Python接口",'./test')
tts.save("./test.mp3")
print('ok')In [ ]:
#百度语音在线
from aip import AipSpeech
""" 你的 APPID AK SK """
APP_ID = '17553946'
API_KEY = 'i5LBXalkBn2KHTqdifesA1EB'
SECRET_KEY = '1ktP6qDH7nMFHjotRdKpnI13w41Bvk59'
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
result = client.synthesis('军士上前,将英玉兰架起,两个抓着脚踝,两个托住肩头,一起用力,英玉兰无奈分开两条大浪腿,露出骚屄,被举下。', 'zh', 5, {
'vol': 5,'per': 4,
})
# 识别正确返回语音二进制 错误则返回dict 参照下面错误码
if not isinstance(result, dict):
with open('./test3.mp3', 'wb') as f:
f.write(result)
else:print(result)In [ ]: