0% found this document useful (0 votes)
3 views6 pages

Text To Speech

Android provides a TextToSpeech class that allows users to convert text into voice in various languages. Users must instantiate the class and set properties like language and pitch using methods such as setLanguage() and setPitch(). The class includes several methods for managing speech, including adding speech, checking if it's speaking, and shutting down the engine.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Text To Speech

Android provides a TextToSpeech class that allows users to convert text into voice in various languages. Users must instantiate the class and set properties like language and pitch using methods such as setLanguage() and setPitch(). The class includes several methods for managing speech, including adding speech, checking if it's speaking, and shutting down the engine.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Text To speech

• Android allows you convert your text into voice. Not


only you can convert it but it also allows you to
speak text in variety of different languages.

• Android provides TextToSpeech class for this


purpose.
• In order to use this class, you need to instantiate an
object of this class and also specify the initListener.
• In initListener you have to specify the properties for
TextToSpeech object , such as its language ,pitch e.t.c.
• Language can be set by calling setLanguage() method.

• Create object of TextToSpeech as below

• TextToSpeech tts=new TextToSpeech(getApplicationContext(), new


TextToSpeech.OnInitListener()
• { @Override
• public void onInit(int status)
• {
• //specify properties of TextToSpeech
• }
• });
• Language can be set by calling setLanguage() method
• The method setLanguage takes an Locale object as
parameter.
• The list of some of the locales available are given below
1 US

2 CANADA_FRENCH
3 GERMANY
4 ITALY
5 JAPAN
6 CHINA

• Once you have set the language, you can


call speak method of the class to speak the text.
Methods of TextToSpeech class
1 addSpeech(String text, String filename)
This method adds a mapping between a string of text and a sound file.

2 getLanguage()
This method returns a Locale instance describing the language.

3 isSpeaking()
This method checks whether the TextToSpeech engine is busy speaking.

4 setPitch(float pitch)
This method sets the speech pitch for the TextToSpeech engine.

5 setSpeechRate(float speechRate)
This method sets the speech rate.

6 shutdown()
This method releases the resources used by the TextToSpeech engine.

7 stop()
This method stop the speak.

You might also like