The Talking Pi programming logic is very simple. When Button1 is pressed, Label1 must display the text that is typed inside Textbox1 and TextToSpeech1 must read out that text. The steps for executing this block program are as follows:
- First, click on the Button1 component and select the when Button1.Click main block:
- Next, since we want to change the text of Label1 when Button1 is clicked, choose the Label1.Text block from the Label1 component:
- Next, drag the Label1.Text block inside the Button1.Click block to join both the blocks. Once both the blocks are joined, you will hear a click sound:
- Now, we want to display the text inside the TextBox in the label component. From the TextBox1 component, select the TextBox1.Text block as follows:
- Next, attach the TextBox1.Text block to the Label1.Text block. Now, when you press the button, the label will display the text that is written inside the Textbox. Label1 is now set to display the text that is inside TextBox1, as follows:
- After this, to read out the text that is inside the textbox, click on the TextToSpeech1 component and choose the call TextToSpeech1.Speak block, as follows:
- Connect this block below the Label1.Text block. Inside the message socket, connect the TextBox1.Text final block. This means that whatever text is written inside the textBox will be spoken as a message by the TextToSpeech1 block, for example:
We have now finished designing our block program. To build and run this app inside your Android smartphone, click on the Build drop-down menu and choose between the two build types, as illustrated in the following diagram:
The first option, App (provide QR Code for .apk), will generate a QR code that you can scan with your Android smartphone (using a QR scanner app). After scanning the QR code, the .apk file of the application will be downloaded inside your Android smartphone. Install the .apk file to test the output of the application.
The second option, App (save .apk to my computer), will generate and download a .apk file inside your computer. You will need to transfer the .apk file from your computer to your smartphone and install the .apk file. I personally prefer the first option as the .apk file is directly downloaded inside the smartphone.
You can also download the MIT AI2 companion application from the Android play store and install it inside your Android smartphone to test the application in real time. So in the play store, search for MIT AI2 Companion and then click on the Install button to install the app. The app page is shown in the following screenshot:
After installing the MIT AI2 Companion app inside your Android smartphone, click on the Scan QR code button or enter the six-digit alphabetical code (next to the QR code) inside the MIT AI2 Companion app, and then click on the Connect with code button. To generate the QR code or the six-digit number, click on Connect and then select AI Companion, as follows: