pyttsx3 save to file

175

pyttsx3 save to file -

import pyttsx3
engine = pyttsx3.init("sapi5")
voices = engine.getProperty("voices")[0] 
engine.setProperty('voice', voices)
text = 'Your Text'
engine.save_to_file(text, 'name.mp3')
engine.runAndWait() # don't forget to use this line

how to record pyttsx3 file using python -

import pyttsx3
from gtts import gTTS

engine = pyttsx3.init(driverName='sapi5')
infile = "tanjil.txt"
f = open(infile, 'r')
theText = f.read()
f.close()

#Saving part starts from here 
tts = gTTS(text=theText, lang='en')
tts.save("saved_file.mp3")
print("File saved!")

Comments

Submit
0 Comments