Untitled
unknown
plain_text
2 years ago
824 B
0
Indexable
Never
package com.example.txttospch; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.speech.tts.TextToSpeech; import android.view.View; import android.widget.EditText; import java.util.Locale; public class MainActivity extends AppCompatActivity { EditText e1; TextToSpeech t1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); e1 = findViewById(R.id.edittext); t1 = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() { @Override public void onInit(int i) { if(i!=TextToSpeech.ERROR){ t1.setLanguage(Locale.UK); } } }); } public void convert(View view){ String toSpeak=e1.getText().toString(); t1.speak(toSpeak,TextToSpeech.QUEUE_FLUSH,null); } }