Skip to content

Commit

Permalink
Add new TTS engine: gTTS
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroetb committed Jul 13, 2019
1 parent c2df72d commit 7bf5488
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ LABEL maintainer="pedroetb@gmail.com"
ARG APT_REPOSITORY="deb http://ftp.de.debian.org/debian stretch main non-free"

ARG GOOGLE_SPEECH_VERSION=1.1.0
ARG GTTS_VERSION=2.0.3
ARG ESPEAK_VERSION=1.48.04+dfsg-5+b1
ARG FESTIVAL_VERSION=1:2.4~release-3+b1

Expand All @@ -31,7 +32,8 @@ RUN echo ${APT_REPOSITORY} >> /etc/apt/sources.list && \
festvox-ellpc11k=${FESTVOX_ELLPC11K_VERSION} \
espeak=${ESPEAK_VERSION} && \
pip3 install \
google_speech==${GOOGLE_SPEECH_VERSION} && \
google_speech==${GOOGLE_SPEECH_VERSION} \
gTTS==${GTTS_VERSION} && \
apt-get remove --purge -y \
python3-pip \
python3-setuptools \
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ First, you should install the supported TTS engines:
```
$ apt install python3 sox libsox-fmt-mp3
$ pip install google_speech
```

### gTTS

# Run only when you need to upgrade
$ pip install --upgrade pip
$ pip install google_speech --upgrade
```
$ apt install python3 sox libsox-fmt-mp3
$ pip install gTTS
```

### Festival
Expand Down Expand Up @@ -103,6 +106,14 @@ You need to be online to communicate with Google servers.

Learn more at https://github.com/desbma/GoogleSpeech

### gTTS

Google Text-to-Speech (gTTS) is a Python library and CLI tool to interface with Google Translate's text-to-speech API.

You need to be online to communicate with Google servers.

Learn more at https://github.com/pndurette/gTTS

### Festival

Festival is a free software multi-lingual speech synthesis workbench that runs on multiple-platforms offering black box text to speech, as well as an open architecture for research in speech synthesis.
Expand Down
29 changes: 20 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ function getCmdWithArgs(fields) {

if (voice === 'google_speech') {
return getGoogleSpeechCmdWithArgs(fields);
} else if (voice === 'gtts') {
return getGttsCmdWithArgs(fields);
} else if (voice === 'festival') {
return getFestivalCmdWithArgs(fields);
} else if (voice === 'espeak') {
Expand All @@ -68,21 +70,31 @@ function getGoogleSpeechCmdWithArgs(fields) {
language = fields.language,
speed = fields.speed,

cmd = 'google_speech',
args = '-l ' + language + ' \"' + text + '\"' + ' -e overdrive 10 speed ' + speed;
cmd = 'google_speech' + ' -l ' + language + ' \"' + text + '\"' + ' -e overdrive 10 speed ' + speed;

return cmd + ' ' + args;
return cmd;
}

function getGttsCmdWithArgs(fields) {

var text = fields.textToSpeech,
language = fields.language,
speed = fields.speed,
speedParam = speed ? ' -s' : '',

cmd = 'gtts-cli' + ' -l ' + language + speedParam + ' --nocheck \"' + text + '\"' + ' | play -t mp3 -';

return cmd;
}

function getFestivalCmdWithArgs(fields) {

var text = fields.textToSpeech,
language = fields.language,

cmd = 'echo "' + text + '" | festival',
args = '--tts --heap 1000000 --language ' + language;
cmd = 'echo "' + text + '" | festival' + ' --tts --heap 1000000 --language ' + language;

return cmd + ' ' + args;
return cmd;
}

function getEspeakCmdWithArgs(fields) {
Expand All @@ -93,10 +105,9 @@ function getEspeakCmdWithArgs(fields) {
speed = Math.floor(fields.speed * 150),
pitch = '70',

cmd = 'espeak',
args = '-v' + language + voiceCode + ' -s ' + speed + ' -p ' + pitch + ' \"' + text + '\"';
cmd = 'espeak' + ' -v' + language + voiceCode + ' -s ' + speed + ' -p ' + pitch + ' \"' + text + '\"';

return cmd + ' ' + args;
return cmd;
}

function onSpeechDone(args, err, stdout, stderr) {
Expand Down
8 changes: 8 additions & 0 deletions views/form.pug
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ html
checked
)
span GoogleSpeech
div.form-check-inline
label.form-check-label
input.form-check-input(
type='radio'
name='voice'
value='gtts'
)
span gTTS
div.form-check-inline
label.form-check-label
input.form-check-input(
Expand Down

0 comments on commit 7bf5488

Please sign in to comment.