利用pyttsx3
import pyttsx3#需要导入包
engine=pyttsx3.init()
engine.say("床前明月光,疑是地上霜")
engine.runAndWait()
【pyttsx3或百度语音合成进行语音合成-python】利用百度语音合成
from aip import AipSpeech#https://ai.baidu.com/tech/speech/asr登陆后,找到语音合成,创建应用,再到应用列表可以看到APP_ID,API_KEY,SECRET_KEY
APP_ID="17245xxx"
API_KEY="bhKZS5gi6pUDr0xxxx"
SECRET_KEY="W3YhTUD21q1KONi3zQtADpxxxx"
client=AipSpeech(APP_ID,API_KEY,SECRET_KEY)
ans=client.synthesis(text="床前明月光,疑是地上霜",options={'per': 1})#option是参数,查看各个参数到https://ai.baidu.com/docs#/TTS-API/top
with open("auido.mp3","wb") as f:
f.write(ans)
推荐阅读
- python学习|windows如何安装并切换不同版本的cuda,更新cuda版本
- python-Django如何可以用真实的IP访问(四)
- 各种算法的Python实现方案
- C++|Leetcode 076 最小覆盖子串 Python C++ 史上最详细题解系列
- raise ImportError(msg.format(path)) ImportError: Something is wrong with the numpy installation
- python|Anaconda 之 更换国内下载镜像
- (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escap
- python安装channels报错(" Failed building wheel for Twisted")
- 利用百度智能云结合Python体验图像识别
- Jieba库与wordcloud库的学习汇总