How to save the output of PyTTSx to wav file

和自甴很熟 提交于 2019-12-02 01:11:45

Assuming you are using Python on a win os, you will need to specify the full path to the subprocess, and of course the full output file path eg;

espeak_path = "C:/Program Files/eSpeak/command_line/espeak.exe"
file_name = "C:/temp/test"
subprocess.call([espeak_path,"-w"+file_name+".wav", text])

Just in case somebody is wondering how to do this on linux instead of windows:

os.system("espeak \"example text to speech\" --stdout > myfile.wav")
from gtts import gTTS
import os
tts = gTTS(text='hi how r u', lang='en')
tts.save("good.wav")
os.system("mpg321 good.wav")

this code will output will be saved in ur python folder where u installed. for various audio format just change extension file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!