Index>Robot Kit>Alter All in One Kit for RPi>Lesson 15 Transferring Python Text to Voice
No related product information!

Lesson 15 Transferring Python Text to Voice

1151

        In this lesson, we will learn how to transfer Python text to voice.

15.1 Components used in this course


image.png



15.2 Wiring diagram (Circuit diagram)

    You need to connect 3.5mm earphones (provided by yourself) to the audio port on the driver board of the Raspberry Pi, as shown below:

image.png


15.3 How to initiate Python text-to-voice function

1. Open the terminal software MobaXterm:


image.png


2. Log in to your Raspberry Pi (the way to log in to Raspberry Pi has been introduced in Lesson 1):

image.png


3. Enter the Course Code folder, this folder stores the sample code program to control the robot, enter the following command:

cd adeept_alter/02CourseCode/01ComponentCode

image.png


4. Enter the command to display the contents of the current directory:

ls

image.png


5. The 14Speech_Text folder stores the sample code of this course. Enter the command to enter this folder:

cd  14Speech_Text

image.png


6. Enter the command to display the contents of the current directory:

ls

image.png


7. Before running this program, we need to make some settings. You need to install the voice environment first, and enter the following commands in the command window:

sudo apt-get install espeak

image.png


8.After the download is complete, you need to install the text-to-voice dependency library. Enter the following command:

sudo pip3 install pyttsx3

image.png


9. Run the program ttv.py and enter the following command:

sudo python3 ttv.py

image.png


10. After running the program, if the program has the following prompt error:

image.png


The reason is that the sound card of the Raspberry Pi is blocked. You need to turn it on again and enter the following command:

sudo nano /etc/modprobe.d/snd-blacklist.conf

After entering, add # before the blacklist snd_bcm2835, press ctrl+x to exit, press y, and then press Enter to save the changes.

image.png


After saving and exiting, you need to restart the Raspberry Pi, and then run sudo python3 ttv.py again.

image.png


11. When you want to terminate the running program, you can press the shortcut key Ctrl+C on the keyboard.


【Attention】:

If you use the built-in Small speaker to play the sound, you may not hear the sound.You can replace it with a headset to play it.