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

Save output to file #6

Open
pypingou opened this issue Dec 4, 2011 · 5 comments
Open

Save output to file #6

pypingou opened this issue Dec 4, 2011 · 5 comments
Milestone

Comments

@pypingou
Copy link

pypingou commented Dec 4, 2011

Hi,

I would be very interesting if instead of playing the sound I could also use the library to save it to a file.
At the moment I have to use system call to do this and using pyttsx for this would be nice.

I wish I could provide a patch but this is beyond my python skills.

@Shenlok
Copy link

Shenlok commented Feb 12, 2013

I'd also be interested in learning how to do this! I intend on using PyTTSx for text-to-speech on a webpage I am serving from a python script.

@kscottz
Copy link

kscottz commented Jul 27, 2013

I would love to have this feature.

@cereal
Copy link

cereal commented Jul 29, 2013

Yeah me too - if you need any help just mail me. I can't find the right place to start this, so if you could tell me where the byte-or-whatever stream is 'created' I could do the rest ..

@parente
Copy link
Collaborator

parente commented Aug 9, 2013

I see two ways to approach this feature. One is to extend the API with a speakToFile method or some such exists and all the platform drivers implement it

A second would be to create a new driver per platform specifically for speaking to disk. This would double the number of drivers, but would keep the existing API.

In either case, code needs to be added per platform driver to output to disk. To the best of my knowledge, all three of the existing drivers (NSSpeechSynthesizer, espeak, and SAPI) have this capability. Finding and reading the doc is where it's at.

If someone has time to implement this feature and associated tests, I'll happily review a pull request. I don't have the cycles to work on it myself right now.

humbled added a commit to humbled/pyttsx that referenced this issue Oct 13, 2013
… for OS X only.

Includes doc and unittest additions
gursimar added a commit to gursimar/pyttsx that referenced this issue Sep 6, 2014
@pettarin
Copy link

Hi @parente .

First of all, thank you for writing pyttsx and its documentation.

I too would like a "write to file" API, instead of flushing the generated data at the output sound device, on Linux.

I have done some research on speak_lib.h, the public .h for the espeak lib, and I think there is no "pre-cooked" API for saving to file the produced wave data. It seems to me that one must write a callback function that flushes the data to file as it comes, with the proper WAVE header and ending flush. Essentially this means mimicking what the -w flag (= write to file) does in the src/espeak.cpp in the source of espeak.

(Full disclosure: I am looking for a lib-based approach to synthesize text in Python (or a C extension), to replace this code which uses subprocess to call the espeak executable: https://github.com/readbeyond/aeneas/blob/master/aeneas/espeakwrapper.py )

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

No branches or pull requests

6 participants