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

Text to Speech language #134

Closed
mariolinux opened this issue Jul 15, 2019 · 12 comments
Closed

Text to Speech language #134

mariolinux opened this issue Jul 15, 2019 · 12 comments
Labels
enhancement New feature or request

Comments

@mariolinux
Copy link

Can you add the language argument to get a better TTS?
You could use the language of the eBook, if available in the eBook's metadata, or, if not available, a sort of (but I don't know how) language discovery feature.
Thanks and congratulations for the project.

@itprojects
Copy link
Contributor

You could switch the voice manually with espeak-ng -v myvoice , changing myvoice to whatever your system has. This isn't ideal, but it might do the job, for now.

@johnfactotum
Copy link
Owner

It should be possible to parse the output of espeak --voices and select one automatically.

@johnfactotum johnfactotum added the enhancement New feature or request label Jul 17, 2019
@lelinhtinh
Copy link

Can you add a {{ text }} template for the case it's in the middle of command? For example:

gtts-cli '{{ text }}' -l fr | play -t mp3 -

@johnfactotum
Copy link
Owner

johnfactotum commented Oct 27, 2019

@lelinhtinh The easiest way to use gtts-cli would be to write a script, something like:

#!/bin/bash
gtts-cli -l fr --file /dev/stdin | play -t mp3 - &
trap 'kill $!; exit 0' INT
wait

And set this script as the TTS command.

@RichardJActon
Copy link

Hi I'm having some trouble getting a script to call a custom voice to work. I initially tried what you posted above. This works fine when invoked from the command line with echo "test" | tts-script.sh. But, when I place the script in the tts command box in foliate and press the read button it just rapidly moves the progress bar through the entire book and does not generate any sound. Do you have any suggestions as to how to make the script work? I'm a little unclear how exactly foliate invokes the command provided and how it chunks up the text to feed to it I took a look at the source but I don't know js.

@johnfactotum
Copy link
Owner

@RichardJActon Which TTS program are you using? Foliate turns the page after the command returns, and then gives it the text of the next page, so it's important that it only returns after it has finished reading.

@kupiqu
Copy link

kupiqu commented Apr 4, 2020

@lelinhtinh The easiest way to use gtts-cli would be to write a script, something like:

#!/bin/bash
gtts-cli -l fr --file /dev/stdin | play -t mp3 - &
trap 'kill $!; exit 0' INT
wait

And set this script as the TTS command.

I was looking exactly for this, in my case I prefer using mpv instead of play -t mp3 but it works the same :)

@johnfactotum
Copy link
Owner

On master, after a83696f, the environment variables FOLIATE_TTS_LANG and FOLIATE_TTS_LANG_LOWER are now available. So one can use:

#!/bin/bash
gtts-cli -l $FOLIATE_TTS_LANG_LOWER --file /dev/stdin | play -t mp3 - &
trap 'kill $!; exit 0' INT
wait

For books that specify more precise language codes -- for example, the books from Standard Ebooks -- it will even read British books with the British voice, and Australian books with the Australian voice, and so on. It's quite interesting.

@archisman-panigrahi
Copy link
Contributor

I had to modify the script slightly to make gTTs work in Foliate installed in an Android phone.

Somehow, play from sox does not work there, and mpv does not work either. I had to use VLC instead.

Also, the output of $FOLIATE_TTS_LANG_LOWER was en-gb, and for some reason gTTs could not recognize this language code. In the script, I had to manually change the language to en.

I have written all the details here https://askubuntu.com/a/1336107/124466 .

@jsuarez314
Copy link

jsuarez314 commented May 24, 2021

Hi I'm having some trouble getting a script to call a custom voice to work. I initially tried what you posted above. This works fine when invoked from the command line with echo "test" | tts-script.sh. But, when I place the script in the tts command box in foliate and press the read button it just rapidly moves the progress bar through the entire book and does not generate any sound. Do you have any suggestions as to how to make the script work? I'm a little unclear how exactly foliate invokes the command provided and how it chunks up the text to feed to it I took a look at the source but I don't know js.

Hi have the same problem that @RichardJActon. I'm using the gtts program. When I invoked echo "test" | gtts_script.sh from the command line the script works. But when I try from foliate, this does not work.

I'm using Foliate on Debian 10 (installed with the deb file)

@johnfactotum
Copy link
Owner

@jsuarez314 Can you post the content of the script? And error messages, if any? Also it might be better to open a separate issue, as this issue is only about TTS language.

@apandada1 I haven't tried it recently, but I can say that it did work before. I think it might be related pndurette/gTTS#245. Maybe one can still get region tags to work with --nocheck. Maybe Foliate should provide a variable for language codes without region codes. Or one can just split on the - character in the Bash script.

@jsuarez314
Copy link

@jsuarez314 Can you post the content of the script? And error messages, if any? Also it might be better to open a separate issue, as this issue is only about TTS language.

@apandada1 I haven't tried it recently, but I can say that it did work before. I think it might be related pndurette/gTTS#245. Maybe one can still get region tags to work with --nocheck. Maybe Foliate should provide a variable for language codes without region codes. Or one can just split on the - character in the Bash script.

I found a partial solution, when I launch foliate from Desktop the gtts script does not work, but when I launch foliate from the terminal the gtts script works fine.

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

No branches or pull requests

8 participants