package com.example.p7; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.speech.tts.TextToSpeech; 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 implements View.OnClickListener, TextToSpeech.OnInitListener { EditText txt; Button btnsp; TextToSpeech txtsp; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txt=(EditText) findViewById(R.id.edittxt); btnsp=(Button) findViewById(R.id.btn); btnsp.setOnClickListener(this); txtsp=new TextToSpeech(getBaseContext(),this); txtsp.setLanguage(Locale.UK); } @Override public void onClick(View v) { String text=txt.getText().toString(); txtsp.speak(text,TextToSpeech.QUEUE_FLUSH,null); } @Override public void onInit(int status) { if(status!=TextToSpeech.ERROR){ Toast.makeText(getBaseContext(),"Success",Toast.LENGTH_LONG).show(); } } }