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.
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 into the Android device by using the following command line:
C:\Users\Bintu\QPython\Scripts>adb push demoTextToSpeach.py /sdcard/qpython/bintuscripts