In this recipe, we will see how an Android device generates sound from the supplied text. That is, the device will speak the specified text.
Making an Android device speak a text input
How to do it...
In this recipe, we will be making use of the ttsSpeak() method, which activates the speech synthesis application on an Android device and the device will generate sound for the supplied text.
Let's take a look at the following steps:
- Type the following code in the Python script demoTextToSpeach.py in the current folder of your computer:
import androidapp = android.Android()
message = "Let us count from 1 to 10"
app.ttsSpeak(message)
for i in range(1,11):
app.ttsSpeak(str(i))
- Copy or push this Python script...