Last active
February 18, 2021 14:45
-
-
Save sourceperl/157fe9e7cb4a2fcb2836957c9d6bb1a3 to your computer and use it in GitHub Desktop.
Text to speak software with espeak and mbrola. Test on Raspberry Pi2 (Raspbian/jessie) and Pi4 (Raspbian/buster).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os, time | |
while True: | |
with open('/sys/class/thermal/thermal_zone0/temp', 'r') as f: | |
cpu_temp = round(float(f.read()) / 1000) | |
os.system('espeak -v mb-fr1 -s 95 \'La température de la CPU est de %s degrés.\'' % cpu_temp) | |
time.sleep(2.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# setup script for Raspberry Pi2 (Raspbian/jessie) | |
# install espeak | |
sudo apt-get install espeak | |
# install mbrola | |
wget http://tcts.fpms.ac.be/synthesis/mbrola/bin/raspberri_pi/mbrola.tgz | |
tar xvzf mbrola.tgz | |
chmod 755 mbrola | |
sudo mv ./mbrola /usr/local/bin/ | |
# install voices for mbrola | |
wget http://tcts.fpms.ac.be/synthesis/mbrola/dba/fr1/fr1-990204.zip | |
sudo unzip fr1-990204.zip -d /opt/mbrola | |
sudo mkdir -p /usr/share/mbrola/voices/ | |
sudo cp -r /opt/mbrola/fr1/* /usr/share/mbrola/voices/ | |
# test it ! | |
espeak -s 125 -v mb/mb-fr1 'installation terminé. On peux maintenant utiliser espeak !' | |
# sample script for use with python | |
# #!/usr/bin/env python | |
# # -*- coding: utf-8 -*- | |
# | |
# import os, time | |
# | |
# var1 = 0 | |
# | |
# while True: | |
# os.system('espeak -v mb-fr1 -s 120 \'variable var1 égale à %s\'' % var1) | |
# var1 += 1 | |
# time.sleep(1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# setup script for Raspberry Pi4 (Raspbian/buster) | |
# install espeak (will be replace by espeak-ng see https://github.com/espeak-ng/espeak-ng) | |
sudo apt-get install espeak | |
# install mbrola (binaries of debian "non-free" category are not available on Raspbian/buster) | |
wget http://ftp.fr.debian.org/debian/pool/contrib/m/mbrola/mbrola_3.3+dfsg-4~bpo10+1_armhf.deb | |
sudo dpkg -i mbrola_3.3+dfsg-4~bpo10+1_armhf.deb | |
rm mbrola_3.3+dfsg-4~bpo10+1_armhf.deb | |
# install voices for mbrola ("non-free" but as it's not binaries packages we can install it) | |
sudo apt-get install mbrola-fr1 mbrola-fr2 | |
# test it ! | |
espeak -s 95 -v mb/mb-fr1 'installation terminé. On peux maintenant utiliser espeak !' | |
# see say_cpu_temp.py sample script for an example of use with python3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment