GNU Linux Debian 11 - text to speech (text2speech) - read out text loud - listen to computer spoken text

instead of reading massively long passages of text (which can become tiresome fast)

it might be nice, to have the computer read out that text?

let’s do that 🙂

multiple choices

there are different Open Source text2speech systems, programs out there…

multi language talent: pico tts

(no not the text editor)

  • supported languages:
    • English, US (en-US) / English, GB (en-GB)
    • Spanish (es-ES)
    • French (fr-FR)
    • German (de-DE)
    • Italian (it-IT)

The Pico service produces audio streams using WAV containers and PCM (signed) codec with 16bit depth.

“The Pico Text-to-Speech (TTS) service uses the TTS binary from SVOX for producing spoken text.”

“You manually need to install the pico2wave binary in order for this service to work correctly. You can, e.g., install it with apt-get on an Ubuntu system” (src)

show me the src: https://github.com/naggety/picotts

<span style="color: #00ffff;">lsb_release -a</span>; # tested on
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:    11
Codename:   bullseye

# if not already, install the genious mplayer & ffmpeg packages :)
# (or some other player that can play wav files)
<span style="color: #00ffff;">su - root
apt update
apt install mplayer ffmpeg</span>

# pre compiled package (not the latest, but might just do the job)
<span style="color: #00ffff;">apt search libttspico-utils
apt install libttspico-utils</span>
libttspico-utils/stable,stable 1.0+git20130326-11 amd64
  Small Footprint TTS (binaries)

# compile from src
# as non-root
<span style="color: #00ffff;">git clone https://github.com/naggety/picotts.git
cd pico/picotts/pico

su - root
apt update; apt install autoconf libtool help2man libpopt-dev debhelper;</span>
Ctrl+D # log off root
<span style="color: #00ffff;">./autogen.sh
./configure 
make

su - root
cd /software/pico/picotts/pico
make install

</span># remove packages (not needed anymore)<span style="color: #00ffff;">
apt-get remove --purge autoconf libtool help2man libpopt-dev debhelper
apt-get autoremove --purge</span>

how to let it read text, usage example:

copy and paste the text the user wants to have read out loud into a file called read.txt

# for US-English
<span style="color: #00ffff;">cat read.txt| pico2wave -l en-US -w ./read.text.wav; mplayer ./read.text.wav;rm -rf ./read.text.wav;</span>

# for UK-English
<span style="color: #00ffff;">cat read.txt| pico2wave -l en-GB -w ./read.text.wav; mplayer ./read.text.wav;rm -rf ./read.text.wav;</span>

# for Spanish
<span style="color: #00ffff;">cat read.txt| pico2wave -l es-ES -w ./read.text.wav; mplayer ./read.text.wav;rm -rf ./read.text.wav;</span>

# for French
<span style="color: #00ffff;">cat read.txt| pico2wave -l fr-FR -w ./read.text.wav; mplayer ./read.text.wav;rm -rf ./read.text.wav;</span>

# for German
<span style="color: #00ffff;">cat read.txt| pico2wave -l de-DE -w ./read.text.wav; mplayer ./read.text.wav;rm -rf ./read.text.wav;</span>

# for Italian
<span style="color: #00ffff;">cat read.txt| pico2wave -l it-IT -w ./read.text.wav; mplayer ./read.text.wav;rm -rf ./read.text.wav;

</span>

script it 🙂

usage example of the script:

<span style="color: #00ffff;">/scripts/read.sh read.txt en</span>
# create the script<span style="color: #00ffff;">
vim /scripts/read.sh</span>

<span style="color: #ff6600;">#!/bin/bash

echo "... converting text $1 to computer spoken audio"

if [ "$2" = "en" ];
then
    # for US-English
    cat $1 | pico2wave -l en-US -w ./read.text.wav;
fi

if [ "$2" = "uk" ];
then
    # for UK-English
    cat read.txt| pico2wave -l en-GB -w ./read.text.wav;
fi

if [ "$2" = "es" ];
then
    # for Spanish
    cat read.txt| pico2wave -l es-ES -w ./read.text.wav;
fi

if [ "$2" = "fr" ];
then
    # for French
    cat read.txt| pico2wave -l fr-FR -w ./read.text.wav;
fi

if [ "$2" = "de" ];
then
    # for German
    cat read.txt| pico2wave -l de-DE -w ./read.text.wav;
fi

if [ "$2" = "it" ];
then
    # for Italian
    cat read.txt| pico2wave -l it-IT -w ./read.text.wav;
fi

echo "... starting playback"
mplayer ./read.text.wav;

echo "... removing temporary wav file"
rm -rf ./read.text.wav;

</span>

english only but with accents: flite

flite supports only english (?) but that even in DIFFERENT ACCENTS! X-D

<span style="color: #00ffff;">su - root
apt update; apt install flite;</span>
flite/stable,now 2.2-2 amd64 [installed]
  Small run-time speech synthesis engine

# get more english language accents
<span style="color: #00ffff;">wget -r --no-parent --no-directories --accept flitevox http://www.festvox.org/flite/packed/flite-2.0/voices/
</span>
# usage example
<span style="color: #00ffff;">cat speak.txt | flite -voice /path/to/flite/voices/cmu_us_awb.flitevox
</span>

Links:

creditz: https://cstan.io/?p=11840&lang=en

#linux #gnu #gnulinux #opensource #administration #sysops #text #speech #audio

Originally posted at: https://dwaves.de/2022/04/25/gnu-linux-debian-11-text-to-speech-text2speech-read-out-text-loud-listen-to-computer-spoken-text/

There are no comments yet.