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

Added an option of output: the wave array directly to memory (as a list of number 16-bit) #96

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

redreamality
Copy link

CAUTION. only implemented for Windows sapi5 driver.

nateshmbhat and others added 10 commits January 23, 2020 23:10
The pypi link was to pypi, not to the pyttsx project page on pypi.
- the platform specific dependencies are already handled by `extras_require`
- when the wheel is built on macos / windows the `install_requires` will contain extra values (it appears the one on pypi for the latest version was built on macos)
add to_memory function
WARNING, only implemented for windows
usage:
>>> engine.to_memory(ss, audio_array)
>>> engine.runAndWait()
>>> data = np.expand_dims(np.asarray(audio_array[0] ,dtype=np.int16),axis=1)
>>> # you can test the output by: scipy.io.wavfile.write('name.wav',22050,data)
@redreamality redreamality changed the title Add to memory function Added an option of output: the wave data to memory (as a list of number 16-bit) Feb 23, 2020
@redreamality redreamality changed the title Added an option of output: the wave data to memory (as a list of number 16-bit) Added an option of output: the wave array directly to memory (as a list of number 16-bit) Feb 23, 2020
@TotallyAProgrammer
Copy link
Contributor

@redreamality This will most likely not be merged until the conflicts are resolved in your repository.

@Jiangshan00001
Copy link

@redreamality @nateshmbhat i commited it here: https://github.com/Jiangshan00001/pyttsx4
and you can use it like

pip install pyttsx4

@nateshmbhat
Copy link
Owner

@Jiangshan00001 can u raise a PR here for the same?

@Jiangshan00001
Copy link

sure @nateshmbhat

@nateshmbhat
Copy link
Owner

nateshmbhat commented Sep 14, 2024

Hi @Jiangshan00001 . there are conflicts in this PR. would you be open to resolve the conflicts and update the PR. would be glad to merge it.

@redreamality
Copy link
Author

conflicts resolved

Copy link
Owner

@nateshmbhat nateshmbhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo here can u please update

pyttsx3/driver.py Outdated Show resolved Hide resolved
@willwade
Copy link
Collaborator

willwade commented Sep 27, 2024

I see now this and PR #270. Pretty similar

@redreamality its been a while. Whats your thoughts on save_to_memory. This doesnt sit with me right as a method name.. its not really in memory - its a save_to_bytes isnt it?

Hold on - I've looked again and no , i see what you are doing. Thats pretty specific. What about if this module did have a save_to_bytes. Then in your local script you would be able to just pile up the PCM 16 bytestream however you want. Wouldnt that be more useful?

NB: It would be a bit like this:

https://github.com/willwade/tts-wrapper?tab=readme-ov-file#2-real-time-playback-using-sounddevice

@willwade
Copy link
Collaborator

willwade commented Sep 30, 2024

FYI.. Ive been digging into this more. SAPI does have a SAPI.SpMemoryStream method as @Jiangshan00001 has done.. But in Mac I cant find a native way of doing this so you would have to write a hack of writing to a temp file and then parsing it out. or using more frameworks like AVFoundation..

eSpeak should be easy to do..

I would push my PR but its
only for SAPI & espeak

My branch is here https://github.com/willwade/pyttsx3/tree/to_bytestream

If I figure out even a hack method for nsss I'll do a PR

@redreamality
Copy link
Author

FYI.. Ive been digging into this more. SAPI does have a SAPI.SpMemoryStream method as @Jiangshan00001 has done.. But in Mac I cant find a native way of doing this so you would have to write a hack of writing to a temp file and then parsing it out. or using more frameworks like AVFoundation..

eSpeak should be easy to do..

I would push my PR but its only for SAPI & espeak

My branch is here https://github.com/willwade/pyttsx3/tree/to_bytestream

If I figure out even a hack method for nsss I'll do a PR

I'm just providing a method that keeps the stream in memory, without the need of any temp file> FYI.. Ive been digging into this more. SAPI does have a SAPI.SpMemoryStream method as @Jiangshan00001 has done.. But in Mac I cant find a native way of doing this so you would have to write a hack of writing to a temp file and then parsing it out. or using more frameworks like AVFoundation..

eSpeak should be easy to do..

I would push my PR but its only for SAPI & espeak

My branch is here https://github.com/willwade/pyttsx3/tree/to_bytestream

If I figure out even a hack method for nsss I'll do a PR

I'm just providing a method that keeps the stream in memory, without the need of any temp file. This method, as i mentioned at very beginning, just works for windows.

@willwade
Copy link
Collaborator

willwade commented Oct 4, 2024

Yeah. I've done it now for espeak too now. I think if we can do a method for nsss it's worth reviewing this. I'll push it as a WIP for review

@willwade willwade mentioned this pull request Oct 4, 2024
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

Successfully merging this pull request may close these issues.

7 participants