Android is providing Text To Speech and its speaks many different languages with different names, country or others.
Activiy_main.xml :-
Activiy_main.xml :-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:textAlignment="center"> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="speak"
android:id="@+id/button"
android:layout_gravity="center_horizontal" /> <EditText android:layout_width="124dp"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_gravity="center_horizontal"
android:hint="input" /> </LinearLayout>MainActivity.java :-
package com.kiranapp; import android.speech.tts.TextToSpeech; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import java.util.Locale; public class MainActivity extends AppCompatActivity { Button speakbtn; EditText input; TextToSpeech tts; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); speakbtn=(Button)findViewById(R.id.button); input=(EditText)findViewById(R.id.editText); tts=new TextToSpeech(getApplicationContext(), new
TextToSpeech.OnInitListener() { @Override
public void onInit(int status) { Toast.makeText(MainActivity.this, "Text to Speech engine is Intialized", Toast.LENGTH_SHORT).show(); } }); speakbtn.setOnClickListener(new
View.OnClickListener() { @Override public void onClick(View v) { String name=input.getText().toString(); String s1="Android"; tts.speak(s1,RESULT_OK,null); tts.setLanguage(Locale.UK); } }); } }Output :-
![]() |
| Android Text To Speech |

Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more..Android Training in chennai | Android Training in chennai with placement
ReplyDeleteThis is a nice, clean example of integrating Android’s TextToSpeech engine. The straightforward approach—initializing TTS in onCreate(), setting up a speakbtn click listener, and calling tts.speak()—makes it easy for beginners to understand the core flow. I also appreciated the use of Locale.UK for English pronunciation, which is a detail many quick-start tutorials overlook. For modern apps, it's worth noting that TTS initialization is asynchronous, so adding a proper onInit() callback with language availability checks can prevent crashes on devices where speech data isn't yet installed. If you're looking to deepen your skills in Android development and automation, I've found a great resource for DevOps Training with Placement in Electronic City. Thanks for sharing this helpful guide.
ReplyDeleteThanks for this practical walkthrough of TextToSpeech. Beyond just "cool factor," TTS plays a crucial role in making apps more accessible—helping users with visual impairments or reading difficulties, and even enabling hands-free scenarios. Your example of reading the user's input text is a solid foundation that can be extended into features like audiobook players, navigation prompts, or voice assistants. For developers looking to build robust, accessible apps, understanding how to test and deploy these features reliably across devices is essential. That's why, alongside Android development, I've been building my skills through Job Oriented DevOps Training Electronic City, which focuses on CI/CD, automation, and cloud deployment. Keep up the great work.
ReplyDelete