Learn Pain Less

HomeOur TeamContact
Android
How to use Text To Speech inside RecyclerView in Android
Pawneshwer Gupta
Pawneshwer Gupta
July 27, 2020
1 min
How to use Text To Speech inside RecyclerView in Android

How to use Text To Speech inside RecyclerView in Android

What is TTS (Text To Speech)?

TSS or Text To Speech is library provided by Android, which is used to convert any word into voice. This means it can speak any word or phrase provided to this library.

So if you are creating Android Application which require some speaking words then you don’t need to record voice and play inside your application. You can simply pass your words to this library and it will do rest of the things.

We will use android.speech.tts.TextToSpeech library to convert our Strings into voice.

Overview to TTS

  • First step is to create instance of TextToSpeech.
  • Pass context to TextToSpeech’s contructor and Callback (which will be called when TextToSpeech will ready).
  • There is 3rd optional parameter which is “engine” which is used to pass custom TextToSpeech engine. (eg. Samsung TTS etc.).
  • After creating instance call speak() function from instance and it will speak the provided string.
  • You can also specify language of your text to TextToSpeech library.

Example Project:

TextToSpeech inside RecyclerView:

Code of MainActivity.kt
Code of activity_main.xml
Code of SpeechAdapter.kt
Code of adapter_item_speech.xml

Full Source Code

SpeechTextRecyclerView on Github

Star this github repository and Share with your friends as well.

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Tags

Text To SpeechRecyclerViewandroid

Share


Pawneshwer Gupta

Pawneshwer Gupta

Software Developer

Pawneshwer Gupta works as a software engineer who is enthusiastic in creating efficient and innovative software solutions.

Expertise

Python
Flutter
Laravel
NodeJS

Social Media

Related Posts

EditText editable deprecated android | How to use inputType in Android
EditText editable deprecated android | How to use inputType in Android
July 26, 2020
1 min
Learn Pain Less  © 2024, All Rights Reserved.
Crafted with by Prolong Services

Quick Links

Advertise with usAbout UsContact Us

Social Media