johnfactotum / foliate

Read e-books in style
https://johnfactotum.github.io/foliate/
GNU General Public License v3.0
6.45k stars 298 forks source link

TTS stopping problem #125

Closed itprojects closed 5 years ago

itprojects commented 5 years ago

Starting TTS is easy. Stopping takes some time (several sentences). Is there any way to send a signal to the other process "end now!". Also, maybe add the festival to the debian and Readme.md files.

johnfactotum commented 5 years ago

I believe Festival only stops at the next period (.) after receiving SIGTERM. But using SIGINT seems to work now.

johnfactotum commented 5 years ago

Okay, SIGINT stops instantly when using flatpak-spawn, but still reads to the end of the sentence when called directly.

itprojects commented 5 years ago

Maybe flatpak-spawn shouldn't be used at all, since not everyone uses flatpak, but it's good for research purposes.

Blocking thread problem?

Do you get the impression that you have to press stop twice, for the program to stop at the nearest '.'?

Why festival? Have you tried espeak with mbrola voices, it reads much better. Sometimes ignores superscripts, like a real reader should.

johnfactotum commented 5 years ago

flatpak-spawn is only use when the a process failed to spawn without it, and then if Flatpak is not used, then it would just do nothing. If there's a better way to handle this I'd very much like to hear it.

Festival in general is a bit hard to kill. Perhaps it's doable via some trick but I'm not an expert in process management.

Originally I wanted to use speech-dispatcher, but it doesn't have an easy shell API. espeak has pretty much the same shell interface, and by replacing ['festival', '--tts'] with ['espeak'] in the current TTS code, everything works with espeak, too.

itprojects commented 5 years ago

Is espeak easier to terminate. Does it stop on the spot?

itprojects commented 5 years ago

Try this:

  1. espeak-ng -v mb-en1 -a 100 -g 1 -p 50 -s 160
  2. Type an English sentence, then press enter.

espeak-ng is the new espeak and should have more and longer support life.

itprojects commented 5 years ago

You might need to install packages: mbrola mbrola-en1

johnfactotum commented 5 years ago

I've actually only tested with espeak-ng and not espeak, and it stops on SIGINT and works quite well. You can easily test this yourself by replacing the argv ['festival', '--tts'] with ['espeak'] or optionally along with its command line options here: https://github.com/johnfactotum/foliate/blob/07510d70edbe02ee3ecb04dd1bf6159c62f3fd40/src/main.js#L2594

itprojects commented 5 years ago

So can we switch to espeak-ng?

In the future it would be great to be able to modify the TTS parameters like speed, pitch voice, etc.

johnfactotum commented 5 years ago

Check the latest commit. TTS is now disabled by default and you can set any command you want in gsettings.

itprojects commented 5 years ago

Thanks!

johnfactotum commented 5 years ago

I think this can be closed now because (1) espeak works, (2) Festival not stopping immediately on SIGINT or SIGTERM is probably best dealt with upstream, and (3) if there's a way to kill Festival instantly, it'd easy to write a wrapper script to do just that when receiving SIGINT, and then set that script as the TTS command.