■ サンプル
import android.speech.tts.TextToSpeech; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.EditText; import android.widget.Toast; import java.util.Locale; public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener { private TextToSpeech tts; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // TextToSpeechオブジェクトの生成 tts = new TextToSpeech(this, this); } @Override protected void onDestroy() { super.onDestroy(); if (null != tts) { // TextToSpeechのリソースを解放する tts.shutdown(); } } @Override public void onInit(int status) { if (TextToSpeech.SUCCESS == status) { Locale locale = Locale.ENGLISH; if (tts.isLanguageAvailable(locale) >= TextToSpeech.LANG_AVAILABLE) { tts.setLanguage(locale); } else { Log.d("", "Error SetLocale"); } } else { Log.d("", "Error Init"); } } protected void onClickButton(View view) { try { String value = ((EditText)findViewById(R.id.inputEditText)).getText().toString(); this.speechText(value); } catch (Exception ex) { ex.printStackTrace(); } Toast.makeText(this, "Done!!", Toast.LENGTH_LONG).show(); } private void speechText(String value) { if (0 < value.length()) { if (tts.isSpeaking()) { // 読み上げ中なら止める tts.stop(); } // 読み上げ開始 tts.speak(value, TextToSpeech.QUEUE_FLUSH, null); } } }