mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-06 15:12:24 +00:00
Use API 21.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
package com.reecedunn.espeak;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -27,6 +28,7 @@ import java.util.Locale;
|
||||
/*
|
||||
* Returns the sample text string for the language requested
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public class GetSampleText extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@@ -89,8 +89,13 @@ public class eSpeakActivity extends Activity {
|
||||
|
||||
findViewById(R.id.speak).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onClick(View v) {
|
||||
mTts.speak(mText.getText().toString(), TextToSpeech.QUEUE_ADD, null);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mTts.speak(mText.getText().toString(), TextToSpeech.QUEUE_ADD, null, null);
|
||||
} else {
|
||||
mTts.speak(mText.getText().toString(), TextToSpeech.QUEUE_ADD, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -189,15 +194,28 @@ public class eSpeakActivity extends Activity {
|
||||
mTts = new TextToSpeech(this, mInitListener);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private Locale getTtsLanguage() {
|
||||
if (mTts != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
android.speech.tts.Voice voice = mTts.getVoice();
|
||||
if (voice != null) {
|
||||
return voice.getLocale();
|
||||
}
|
||||
} else {
|
||||
return mTts.getLanguage();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void populateInformationView() {
|
||||
mInformation.clear();
|
||||
|
||||
if (mTts != null) {
|
||||
Locale language = mTts.getLanguage();
|
||||
if (language != null) {
|
||||
final String currentLocale = getString(R.string.current_tts_locale);
|
||||
mInformation.add(new Pair<String,String>(currentLocale, mTts.getLanguage().getDisplayName()));
|
||||
}
|
||||
Locale language = getTtsLanguage();
|
||||
if (language != null) {
|
||||
final String currentLocale = getString(R.string.current_tts_locale);
|
||||
mInformation.add(new Pair<String, String>(currentLocale, language.getDisplayName()));
|
||||
}
|
||||
|
||||
final String availableVoices = getString(R.string.available_voices);
|
||||
|
||||
Reference in New Issue
Block a user