Python语音转文字
import pyttsx3import ioimport syssys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')engine = pyttsx3.init()engine.setProperty('voice', 'zh')engine.say('请输入您要播放的文件路径')engine.runAndWait()
·
import pyttsx3
import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
engine = pyttsx3.init()
engine.setProperty('voice', 'zh')
engine.say('请输入您要播放的文件路径')
engine.runAndWait()
path_dir = input('请输入您要播放的文件路径后回车:')
with open(path_dir, 'r') as f:
engine = pyttsx3.init()
engine.setProperty('voice', 'zh')
lines = f.readlines()
print('要说的话:',lines)
for line in lines:
engine.say(line)
engine.runAndWait()
"""Saving Voice to a file"""
engine = pyttsx3.init()
engine.setProperty('voice', 'zh')
# On linux make sure that 'espeak' and 'ffmpeg' are installed
engine.save_to_file('迪迦奥特曼(dijia.top)', 'test.mp3')
engine.runAndWait()
engine.stop()
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)