ndarilek / tts-rs

115 stars 25 forks source link

Q: Speech as Vec<u8> or &[u8] #12

Open TobiasDeBruijn opened 3 years ago

TobiasDeBruijn commented 3 years ago

Hi there,

Silly question, maybe, but is it possible to get the produced speech as a Vec or a &[u8]? I have not been able to find a way to get it.

Thanks!

ndarilek commented 3 years ago

Sorry, no support for that yet. I'd love to have it, though, and would accept a PR. Most backends support it, and I think UWP even creates the bytes before sending them to a media player, so speak can probably use that functionality and just pass along its output.

If anyone wants to implement it, I'd probably call the method and feature synthesize.

leecbaker commented 2 years ago

I'm quite interested in having the ability to get the generated raw audio samples, specifically for the WinRT and AVFoundation backends.

I think for some backends, its a little bit nontrivial- some will want to progressively stream out samples as they are generated, and the generated audio formats (and sample rates) may vary between backends.

I don't know if this would help it get done more quickly, but I'd be happy to offer a bounty to anybody who implements this feature in a manner acceptable to @ndarilek, creates a PR, and gets it merged to this repository. $40 PayPal each for the WinRT and AVFoundation backends, or $80 together.

usagi commented 1 year ago

I am currently to use tts crate in combination with rodio crate and other speech synthesis systems in the asynchronous processing using tokio. I am waiting to the day when Issue-#12 is completed and PR-#30 are merged into the tts mainstream.

Because on Windows, opening a rodio OutputStream will cause tts is_speaking() to always return true from then on, making it extremely difficult to use them together. I hope that synthesize() will be merged into tts to improve its usability with other systems, cheers.


note: For those who have encountered the same problem as I did and arrived at this Issue. While it is not always advisable to use a branch in development for a product, a product in demand must be released.

[dependencies]
# tts = "0.25.6"
[target.'cfg(windows)'.dependencies]
# tts Issue-#12, PR-#30 synthesize branch
tts = { git = "https://github.com/Bear-03/tts-rs", branch = "synthesize" }