1
0
mirror of https://github.com/ndarilek/tts-rs.git synced 2024-11-01 02:09:37 +00:00
Commit Graph

164 Commits

Author SHA1 Message Date
06eb32b6d4 Make module imports more consistent. 2020-12-30 14:23:31 -06:00
8d6f40b1a5 Finish callback implementation. 2020-12-30 12:19:44 -06:00
0ea46b29b2 Partially implement callbacks. Unfinished due to lazy_static inconsistencies. 2020-12-30 11:37:46 -06:00
c92b67127c Support is_speaking. 2020-12-30 10:15:37 -06:00
733b17fe2c Log TTS initialization failures. 2020-12-30 10:10:49 -06:00
440154502b Clear some unused variable warnings. 2020-12-30 10:07:27 -06:00
2120de8756 Support pitch. 2020-12-30 10:06:18 -06:00
e1c2171833 Support stopping. 2020-12-30 09:49:13 -06:00
22ee9863d6 Return utterance IDs when speech succeeds. 2020-12-30 09:44:47 -06:00
5634fdb393 Block initialization until TTS finishes initializing from Android. 2020-12-30 09:24:13 -06:00
1ac0b91981 Add ugly hack to prove that speech works. 2020-12-29 19:25:56 -06:00
32f57d8578 Speak calls pass to Java, but don't work since something isn't bound to the engine. 2020-12-29 17:25:58 -06:00
f58f875fdf Guess I don't need a global VM. 2020-12-29 15:48:18 -06:00
84926ea110 Store the TTS object in the struct. 2020-12-29 15:47:11 -06:00
da8260cba8 Store the TTS object in the struct. 2020-12-29 15:45:56 -06:00
965bea0adf TTS seems to initialize now. 2020-12-29 14:10:39 -06:00
fc20431916 Refactor Android example to full, self-contained app. 2020-12-29 11:15:24 -06:00
5849e340c9 Add initial Android stubs. 2020-12-27 09:41:34 -06:00
d8f2b3fb00 I'll do my own queuing, MediaPlaybackList is either the wrong tool for the job or way too buggy. 2020-12-07 21:35:07 -06:00
a905439d9c Add strategic backoff in WinRT backend to (hopefully) eliminate a deadlock. 2020-12-07 14:58:59 -06:00
f4952ad132 UWP tweaks and optimizations.
* Initialized TTS `MediaPlayer` in real-time mode.
* Set media category to speech.
* More aggressively drop locks to prevent deadlocks.
* Remove checks of queued items that are no longer necessary.
* Made `is_speaking` check both media player state and queued item count.
* Return eagerly from `stop` if speech isn't in progress, thus eliminating more locks.
2020-11-25 10:07:28 -06:00
669c94af36 We don't need autoplay. 2020-11-23 17:20:55 -06:00
d97796fff7 Eliminate a Clippy warning. 2020-11-17 16:03:03 -06:00
590d6369fb Remove debugging printlns. 2020-11-17 10:25:21 -06:00
6a706f36ab Fix double-speaking bug for good, hopefully. 2020-11-11 10:27:03 -06:00
031e0ff23f Fix more queuing issues under WinRT. 2020-11-03 12:02:16 -06:00
6b74afe503 Remove unused variable. 2020-11-03 11:24:09 -06:00
289a35dc83 Don't double-speak previous item when not flushing queue. 2020-11-03 11:20:02 -06:00
9c98026978 Don't re-initialize a player, just clear the item list. 2020-11-03 11:11:49 -06:00
d3e05b5a7a Revert "Pass TTS instance as first argument to utterance callbacks."
This appears to break callbacks, and is of limited utility.

This reverts commit 29c0a8463e.
2020-11-03 11:03:55 -06:00
29c0a8463e Pass TTS instance as first argument to utterance callbacks. 2020-11-02 22:40:30 -06:00
cf0ad2221e Derive Debug. 2020-11-02 21:44:47 -06:00
551bb1292e Make TTS clonable.
Also, add other possibly useful derives.
2020-11-02 21:27:13 -06:00
565aa6d654 Fix issue where is_speaking always returns true under WinRT, and bump version. 2020-11-02 13:30:39 -06:00
5feede0b8f Remove unnecessary debug logs. 2020-11-02 10:11:53 -06:00
0bbda0a90f Remove WinRT code for handling paused player state, which caused issues with queued speech. 2020-10-30 10:23:24 -05:00
fa216a534e Gate Tolk behind use_tolk feature to support compilation on UWP. 2020-10-08 19:07:07 -05:00
88ec7db075 Eliminate accidental deadlock. 2020-10-08 09:44:46 -05:00
0c13c43a77 Fix incorrect error code name. 2020-10-08 08:16:01 -05:00
6f12974ce4 Implement stop callback on MacOS. 2020-10-08 08:07:33 -05:00
8c783205c3 Implement utterance_stop callback on most platforms. 2020-10-08 07:56:45 -05:00
174011bbb4 Make UtteranceId use u64 on most platforms, and add additional derives. 2020-10-08 07:16:10 -05:00
François Caddet
d2c42d97f5 the voices::Backend trait is almost stable 2020-09-28 11:18:54 +02:00
François Caddet
3294a82485 some fixes
now build on macOS
2020-09-27 20:35:40 +02:00
François Caddet
e19eb56169 first implementation of a voice trait for macOS
WARN: not tested
2020-09-27 20:04:12 +02:00
François Caddet
f78aed211f fix conflicts 2020-09-26 23:36:15 +02:00
Francois Caddet
8c8dc0ae9f add voices value returned by the backends 2020-09-26 23:03:56 +02:00
c2bbc5ac04 Eliminate more Clippy warnings. 2020-09-26 12:47:18 -05:00
dbac8a3fe0 Eliminate some Clippy warnings. 2020-09-26 12:43:16 -05:00
Francois Caddet
47cbb80595 Merge branch 'develop' into feature/voices 2020-09-26 18:20:10 +02:00
ace5d2fd1f Make compatible with newly-released speech-dispatcher-rs. 2020-09-25 11:33:49 -05:00
589c613bbe Implement FnMut callbacks on AV Foundation, and fix warnings. 2020-09-25 11:14:26 -05:00
1f22843086 Refactor Linux, Windows, and Wasm platforms to use FnMut for callbacks, and bump version. 2020-09-25 11:08:19 -05:00
96e5d21e24 Implement callbacks for WinRT. 2020-09-24 17:56:46 -05:00
a22242af50 Implement callbacks for web backend. 2020-09-24 14:26:30 -05:00
532d5d9b58 Tighten up access. 2020-09-23 12:23:46 -05:00
251fb8d8c1 Implement callbacks on AVFoundation. 2020-09-23 12:21:05 -05:00
bd57075d53 Implement unused framework for AVFoundation callbacks. 2020-09-23 11:28:56 -05:00
36a12597de Merge branch 'v0.7' of https://github.com/ndarilek/tts-rs into v0.7 2020-09-23 11:00:41 -05:00
6788277a4d Implement framework for utterance callbacks in Windows backends, though they aren't currently called. 2020-09-23 10:31:21 -05:00
61522610cd Implement utterance begin/end callback framework, and set up for Speech-Dispatcher. 2020-09-23 10:12:51 -05:00
f5f11b7cdf Switch to using MediaPlaybackItem as WinRT utterance ID. 2020-09-22 14:51:59 -05:00
017aa8863b Remove unused import and fix i~~OS builds. 2020-09-22 14:30:17 -05:00
6b023c3071 Add AV Foundation support for returning utterance IDs. 2020-09-22 14:08:19 -05:00
4816ec575c Make speak calls return an utterance ID, where possible. 2020-09-22 12:40:03 -05:00
d6508edd12 Remove workaround for incorrect Tolk string handling, pin minimum working version, and bump version. 2020-09-21 15:13:22 -05:00
François Caddet
97f1de5724 Merge branch 'develop' into feature/voices 2020-09-05 12:27:19 +02:00
François Caddet
335ac710a6 add unimplemented functions forvoices feature on every backends 2020-09-05 12:07:51 +02:00
François Caddet
b238c8c938 fix return type of AVSpeechSynthesisVoice:new 2020-09-05 11:30:11 +02:00
François Caddet
0fb6c62d83 fix some parameters types and implement set_voice
We have an ilegal hardware instruction in
backend::av_foundation::voices::AVSpeechSynthesisVoice::new(identifier)
when sending voiceWithIdentifier. Is it because the runLoop is not
runing when it's called?
2020-09-04 15:48:56 +02:00
François Caddet
6ed94686f3 implement set_voice for AVFoundation backend
- TODO: test the implementation
- fixed: set_voice mutability of self parameter
2020-09-03 18:40:32 +02:00
François Caddet
5b0d1b6621 Add voices feature
Implemented for AVFoundation backend but set_voice has no effect for now
Warning: does not build on Linux or windows for now
2020-09-03 16:50:11 +02:00
665013fdff Split text sent to Tolk backend to account for some sort of length limit.
Tolk seems to fail on strings larger than 325 characters in length. Here we:
* Send any strings with 300 or fewer characters through directly.
* For larger strings, split on whitespace boundaries, then create and send buffers of 300 or fewer characters.

This may not handle internationalized text, and may not handle someone bombarding TTS with a giant word. PRs for either welcome.
2020-09-02 11:40:08 -05:00
6c091f3284 Switch Speech-dispatcher initialization to threaded mode so callbacks work and is_speaking is correct. 2020-08-25 11:50:25 -05:00
d3ffd5078f cargo fmt 2020-08-24 16:46:57 -05:00
1507527175 Add Default implementation for Features so backends need only specify features they actually support. 2020-08-24 16:44:00 -05:00
951e31b284 Implement is_speaking For Speech-dispatcher. 2020-08-19 21:28:30 -05:00
a1e4215ea7 Normal volume of speech-dispatcher is 100, not 0. 2020-08-18 15:19:34 -05:00
2f85c3b2bf Add iOS build. 2020-08-18 15:16:30 -05:00
c5b1ff1944 Add AVFoundation backend, used automatically on MacOS 10.14 and above. 2020-08-13 11:08:00 -05:00
2d0ab8889a Eliminate a warning. 2020-08-13 06:58:16 -05:00
cc2a4c12f7 Rename ns_speech_synthesizer backend to appkit. 2020-08-13 06:46:16 -05:00
75fd320d3f Implement rate/volume-setting for NSSpeechSynthesizer, along with other tweaks.
Unfortunately, there seems to be a difference in how the `hello_world` example processes rate and volume changes. I'm not sure if it doesn't adjust rate for samples while speaking. In any case, arguably there are just going to be differences in platforms that I can't account for, so this may just have to be. Hopefully it doesn't interfere with actual usage.
2020-08-12 15:41:57 -05:00
dc1c00f446 Good news: NSSpeechSynthesizer speech now queues. Bad news: my brain bleeds. 2020-08-12 15:14:17 -05:00
7eccb9f573 Clean up println! and comparison calls. 2020-08-12 09:54:25 -05:00
427ca027be Add Drop implementation. 2020-08-12 09:52:16 -05:00
47bfe768e6 Get delegates working so speech interruption/queuing should now be possible.
* Fix broken delegate method signature.
* Add `NSRunLoop` into `hello_world` example so delegates are called. Presumably, MacOS apps already run one of these, but the example didn't.
2020-08-12 09:49:51 -05:00
faadc0e3b7 Still doesn't work, but at least it doesn't segfault now. 2020-08-11 14:44:52 -05:00
753f6c5ecd WIP: Initial support for MacOS/NSSpeechSynthesizer.
* Add necessary dependencies, build script, and `NSSpeechSynthesizer` backend.
* Get very basic speech working.

Needs a delegate to handle queued speech, and currently segfaults if one is set.
2020-08-11 12:11:19 -05:00
e1bb6741a9 Correctly indicate that WinRT supports detection of speaking. 2020-07-07 09:08:44 -05:00
16a6f6378a Under WinRT, recreate player completely when interruption is requested. 2020-07-06 12:52:18 -05:00
1d7c668a4a Sanity-check value to prevent overflow. 2020-07-06 12:14:50 -05:00
d830f44c55 Handle corner case where WinRT speech that doesn't interrupt, and is played after a delay, causes recently-spoken utterances to replay.
`MediaPlayer` only seems to have states for playing and paused, but not stopped. Further, playing when the queue is finished seems to restart playback from the beginning.

Here we clear the list of items to play if the player is paused and we're on the last item. We assume we're done with all items to speak, and clear the list before appending a new item and beginning playback again.

The correct solution is probably to investigate how events work in winrt-rs, but callbacks and Rust have always been a disaster when I've tried them, so I'm hesitant. This does seem to handle the basic scenarios I've thrown at it.
2020-06-17 18:54:34 -05:00
ce8c5f5289 Refactor to use separate tts_winrt_bindings crate, and bump version. 2020-06-17 17:25:43 -05:00
45c7b1afc7 Various WinRT refinements.
* Move autogenerated code to subcrate to speed up compilation.
* `is_speaking` also checks whether a source is opening, in addition to whether it is playing.
* Return to using autoplay.
2020-06-17 16:46:42 -05:00
10a9d56ae5 Remove autoplay setting. 2020-06-14 20:03:11 -05:00
933e850919 Ensure that MediaPlayer for speech is playing. 2020-06-14 19:42:48 -05:00
1526602ad8 Don't close MediaPlayer when stopping speech, and actually support interruption. 2020-06-14 18:56:01 -05:00
4f011e6895 Get Tolk working again.
Two Tolk instances were being created. One checked for the presence of a screen reader. The other actually performed the speech, and was returned as part of the `TTS` instance.

Unfortunately, Tolk doesn't seem to appreciate being called twice. So here we check if a screen reader is detected and, if one is, return the instance that did the detection. Otherwise, error out and return the WinRT backend.
2020-06-11 13:00:24 -05:00
c82ea5f3b3 WinRT fixes.
* Use released `winrt` crate.
* Implement `is_speaking`.
2020-06-09 11:00:37 -05:00