Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

engine.save_to_file() produces empty file #142

Closed
angoodkind opened this issue Sep 4, 2020 · 17 comments
Closed

engine.save_to_file() produces empty file #142

angoodkind opened this issue Sep 4, 2020 · 17 comments
Labels

Comments

@angoodkind
Copy link

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
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.91. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@marek357
Copy link

Hi, Any updates on this? Thanks!

@akkapakasaikiran
Copy link

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.

@shakhrom96bs
Copy link

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'

@shakhrom96bs
Copy link

can anyboda help me.

@shakhrom96bs
Copy link

y*

@awesome-amy
Copy link

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

@bqtd
Copy link

bqtd commented May 11, 2022

what about windows? I did the same thing with windows and it just saved nothing

@MoYuFly
Copy link

MoYuFly commented Aug 5, 2022

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.

@jgframoz
Copy link

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!

@gustavz
Copy link

gustavz commented Jan 3, 2023

For me (on macOS) it is able to create / save a .wav or .aiff file, but these are not readable / playable

@Mateja9991
Copy link

For me (on macOS) it is able to create / save a .wav or .aiff file, but these are not readable / playable

I have the same problem, did you manage to fix it?

@IlyaYakushevskiy
Copy link

For me (on macOS) it is able to create / save a .wav or .aiff file, but these are not readable / playable

The same problem with mac, works on windows tho. Did you solve it?

@bearcatjamboree
Copy link

This still produces empty files on mac, whether you use .wav, .mp3, or .aiff. Anyone know a way to fix this?

@egorgam
Copy link

egorgam commented Apr 1, 2023

I found a small hack to fix it #267. Maybe someone can found better solution to fix it right 🥲

@nateshmbhat
Copy link
Owner

fixed in #271

nateshmbhat pushed a commit that referenced this issue Sep 14, 2024
@varnav
Copy link

varnav commented Jan 17, 2025

CentOS 7 (yeah, I know, it's old)

This code

import pyttsx3
engine = pyttsx3.init() # object creation
engine.save_to_file('Hello World', 'test.mp3')
engine.runAndWait()

or this code (wav)

import pyttsx3
engine = pyttsx3.init() # object creation
engine.save_to_file('Hello World', 'test.wav')
engine.runAndWait()

Produce empty files for me. They have relevant headers for mp3 file or wav file, but nothing else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests