krankzz
Crypto Analyst
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 2
900 XP
In my previous example with my first tutorial, I came up with the image of fading in and out. Now, in this tutorial I will introduce to all of you the power of Basic4Android that convert the text to become a speech.
Before we begin with the code you must need to have three buttons for speech, clear, and exit, and the other one is the EditText(Textbox). You must design your layout like this:
Then the emulator will look like this one:
This is the complete code and I will explain one by one the following syntax:
Note: This code is for initializing TextToSpeech Application.
Dim
tts As
ICOSTextToSpeech
- The tts here is our variable for ICOSTextToSpeech in which I created as the library for my text to speech application. It is like importing the important packages in your program.
Syntax like this one tts.InitializeTTs("tts"
, "en"
)
is that you initialize tts as "tts" for the title and the "en" here is for the default language "English".
The code for our speak button is named Button1 that if the user will click without entering a string in the EditText it will prompt "Please input message to the box". Otherwise this syntax will follow
tts.Speaking(EditText1.Text)
This syntax is for speaking the text you inputted in EditText1. The word "Speaking" here is the method name to convert text to speech.
Button2 is used to clear our Textbox and Button3 is for exiting the application.
Best regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Mobile Developer
09126450702
[email protected]
Visit my page on Facebook at: https://www.facebook.com/BermzISware
Download
Before we begin with the code you must need to have three buttons for speech, clear, and exit, and the other one is the EditText(Textbox). You must design your layout like this:

Then the emulator will look like this one:

This is the complete code and I will explain one by one the following syntax:
- Sub
Process_Globals
- End
Sub
- Sub
Globals
- Dim
tts As
ICOSTextToSpeech
- Dim
Button1 As
Button
- Dim
EditText1 As
EditText
- Dim
Button2 As
Button
- Dim
Button3 As
Button
- End
Sub
- Sub
Activity_Create(FirstTime As
Boolean
)
- Activity.LoadLayout("Main"
)
- Activity.Title="TextToSpeech - Lyndon Bermoy"
- tts.InitializeTTs("tts"
, "en"
)
- End
Sub
- Sub
Activity_Resume
- End
Sub
- Sub
Activity_Pause (User Closed As
Boolean
)
- End
Sub
- Sub
Button1_Click
- If
EditText1.Text = ""
Then
- Msgbox ("Please input message to the box"
,""
)
- EndIf
- tts.Speaking(EditText1.Text)
- End
Sub
- Sub
Button3_Click
- ExitApplication
- End
Sub
- Sub
Button2_Click
- EditText1.Text = ""
- End
Sub
Note: This code is for initializing TextToSpeech Application.
Dim
tts As
ICOSTextToSpeech
- The tts here is our variable for ICOSTextToSpeech in which I created as the library for my text to speech application. It is like importing the important packages in your program.
Syntax like this one tts.InitializeTTs("tts"
, "en"
)
is that you initialize tts as "tts" for the title and the "en" here is for the default language "English".
The code for our speak button is named Button1 that if the user will click without entering a string in the EditText it will prompt "Please input message to the box". Otherwise this syntax will follow
tts.Speaking(EditText1.Text)
This syntax is for speaking the text you inputted in EditText1. The word "Speaking" here is the method name to convert text to speech.
Button2 is used to clear our Textbox and Button3 is for exiting the application.
Best regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Mobile Developer
09126450702
[email protected]
Visit my page on Facebook at: https://www.facebook.com/BermzISware
Download
You must reply in the thread to view hidden content. Upgrade your account to always see hidden content.