Lesson 13

This is python lesson 13

In this lesson we will be moving on to something a bit random but very cool. It is called espeak. It lets python talk to you. Unfortunately this will require one additional download.

import subprocess

text_1 = ‘”Hello I am talking to you”‘

subprocess.call(‘espeak ‘ +text_1, shell=True)

The above piece of code will make Python say “Hello I am talking to you”. First we import subprocess. Then we say text_1 = ‘”Hello i am talking to you”‘. Around the text you may notice something slightly different. We have to put a single then a double quotation mark to open it then a double then a single to close it. This does matter really matter it doesn’t work otherwise. Then the next line does the talking. Can you use this and what we have learnt so far to make an interactive talking robot. Check out Clever Computer under example codes. You will have to indent it yourself we didn’t make it to easy.