I want to convert text to speech offline using pyttsx3 and I want to save the output to an audio file.
I have seen this question and the first answer would be exactly what I need. I just couldn't get it to function.
When running this:
import pyttsx3
tts = pyttsx3.init()
tts.setProperty('voice', tts.getProperty('voice')[1])
tts.save_to_file("What an amazing day today! I'm gonna go for a swim.", "./filename.mp3")
tts.runAndWait()
It doesn't give me an error, it just doesn't output anything and doesn't create a file. The rest of my could should be correct because if I do:
import pyttsx3
tts = pyttsx3.init()
tts.setProperty('voice', tts.getProperty('voice')[1])
tts.say("What an amazing day today! I'm gonna go for a swim.")
tts.runAndWait()
everything works just fine.
I expected the top bit of code to output to a file, instead, it does nothing. I am running windows 10, latest update. Python 3.7.4 32-bit and pyttsx3 version 2.71 Thank you for your help!
Oh, and one more thing, I know the output of save_to_file is most likely not mp3, but I didn't know what it would be and I needed it in mp3 for my next step, so that's what I called it. If I try to set the file extension to something else, it runs just the same.