pyttsx3
pyttsx3 copied to clipboard
engine.save_to_file() produces empty file
In running the code below, engine.say() works fine. However, when I save the audio to a file, the file is empty. I have also verified this in sox.
I am running pyttsx3 on a Macbook running OS 10.15.6.
import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text") # successfully produced
engine.setProperty('volume',1.0)
volume = engine.getProperty('volume')
print(volume) # prints 1
engine.save_to_file('Hello World', 'test.mp3')
engine.runAndWait()
# engine.stop()
Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.91. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
Hi, Any updates on this? Thanks!
save_to_file seems to work in interactive mode but not in scripting mode.
$ python3
>>> import pyttsx3; engine = pyttsx3.init(); engine.save_to_file('Hello world', 'tmp.mp3'); engine.runAndWait();
Works as expected. But the following two ways don't work (they don't even create an empty file) (I am using Ubuntu 18.04).
$ python3 -c "import pyttsx3; engine = pyttsx3.init(); engine.save_to_file('Hello world', 'tmp.mp3'); engine.runAndWait();"
$ python3 main.py
where main.py is as follows:
import pyttsx3
engine = pyttsx3.init()
engine.save_to_file('Hello world', 'tmp.mp3')
engine.runAndWait()
Note that engine.say() is working (for me) in all three ways of invoking python.
Looking forward to any updates.
Hello I have some issue with this code
import pyttsx3 engine = pyttsx3.init() engine.save_to_file('Hello World' , 'test.mp3') engine.runAndWait()
when I execute this Code. I get : AttributeError: 'Engine' object has no attribute 'save_to_file'
can anyboda help me.
y*
I also got empty file when saving to ".mp3", but simply changing to ".aiff" resolved my issue.
According to Apple's documentation, NSSpeechSynthesizer synthesizes text into a sound (AIFF) file, so ".aiff" should be the supported format. (macOS 10.3+) https://developer.apple.com/documentation/appkit/nsspeechsynthesizer/1448394-startspeakingstring?language=objc
what about windows? I did the same thing with windows and it just saved nothing
me too,but in myself computer Normal operation ,Cloud computer make empty file,the cloud computer does not have a graphics card installed。Windows 10 system installed on cloud computer,can you help me.
I also got empty file when saving to ".mp3", but simply changing to ".aiff" resolved my issue.
According to Apple's documentation, NSSpeechSynthesizer synthesizes text into a sound (AIFF) file, so ".aiff" should be the supported format. (macOS 10.3+) https://developer.apple.com/documentation/appkit/nsspeechsynthesizer/1448394-startspeakingstring?language=objc
That solved my problem! Thanks!
For me (on macOS) it is able to create / save a .wav or .aiff file, but these are not readable / playable
For me (on macOS) it is able to create / save a .
wavor.aifffile, but these are not readable / playable
I have the same problem, did you manage to fix it?
For me (on macOS) it is able to create / save a .
wavor.aifffile, but these are not readable / playable
The same problem with mac, works on windows tho. Did you solve it?
This still produces empty files on mac, whether you use .wav, .mp3, or .aiff. Anyone know a way to fix this?
I found a small hack to fix it https://github.com/nateshmbhat/pyttsx3/pull/267. Maybe someone can found better solution to fix it right 🥲