Text To Speech in Raspberry Pi
Text-to-speech (TTS) is a type of speech synthesis application that is used to create a spoken sound version of the text in a computer document, such as a help file or a Web page. TTS can enable the reading of computer display information for the visually challenged person, or may simply be used to augment the reading of a text message.
Current TTS applications include voice-enabled e-mail and spoken prompts in voice response systems. TTS is often used with voice recognition programs.
Like other modules the process has got its own relevance on being interfaced with, where Raspberry Pi finds its own operations based on image processing schemes. So once image get converted to text and there by it could be converted from text to speech.Character recognition process ends with the conversion of text to speech and it could be applied at any where.
Made the headphone or speaker connected to the Raspberry pi as shown in the related figure.
The first thing to do is run :
|
1 |
lsmod | grep snd_bcm2835 |
and check snd_bcm2835 is listed. If it isn’t then run the following command :
|
1 |
sudo modprobe snd_bcm2835 |
If the module isn’t loaded automatically when you boot then you can force it to load by using the following process :
|
1 2 |
cd /etc sudo nano modules |
Then add ‘snd-bcm2835′ so it looks like this :
|
1 2 3 4 5 6 7 |
# /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be # loaded at boot time, one per line. Lines beginning with "#" are # ignored. Parameters can be specified after the module name. snd-bcm2835 |
By default the output is set to automatically select the default audio interface (HDMI if available otherwise analog). You can force it to use a specific interface using :
|
1 |
amixer cset numid=3 n |
Where <n> is the required interface : 0=auto, 1=analog, 2=hdmi. To force the Raspberry Pi to use the analog output :
|
1 |
amixer cset numid=3 1 |
To check the sound, download an audio file by entering this command;
|
1 |
wget http://www.freespecialeffects.co.uk/soundfx/sirens/police_s.wav |
|
1 |
aplay police_s.wav |
If the sound play in correct manner you can confirm that the analog output works properly.
By default the volume will be very less and to increase it, open the terminal and type the command and a new window will appear;
|
1 |
alsamixer |
Increase the volume option by pressing the up arrow and make it to the maximum.
Exit from the option and play the sound again and feel the difference.
The next process is to perform text to speech conversion. For that espeak module should be installed which is well suited for this purpose.
|
1 |
sudo apt-get install espeak |
After the installation check it by entering the command in the prompt:
|
1 |
espeak Hello |
To perform text to speech conversion using python write the code shown below on a python editor;
|
1 2 3 4 5 |
import os,time def robot(text): os.system("espeak ' " + text + " ' ") robot("I am fine") |
Check the process with different texts and apply it on the suitable applications.
Shop With Us
![]()
- Click here to buy Raspberry Pi 2 from RhydoLabz.
- Click here to buy Raspberry Pi 2 Starter Kit from RhydoLabz.
- Click here to buy Raspberry Accessories from RhydoLabz.
Resources![]()
- Raspberry pi 2 3.5mm audio/video jack
- Get started with Python programming.
- An open source website by Raspberry Pi foundation.
Leave a Reply
You must be logged in to post a comment.