I was wondering if TextToSpeech is supported in Google Glass?
I did something like this:
public class TextToSpeechController implements TextToSpeech.OnInitListener{ private Context mContext; private TextToSpeech tts; public TextToSpeechController(Context context) { Log.e("TEXT TO SPEECH CONTROLLER", "controller"); mContext = context; tts = new TextToSpeech(context, this); } @Override public void onInit(int status) { Log.e("INIT TTS", "INIT"); if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(Locale.ENGLISH); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Toast.makeText(mContext, "This Language is not supported", Toast.LENGTH_LONG).show(); } else { Toast.makeText(mContext, "Ready to Speak", Toast.LENGTH_LONG).show(); speakTheText("Welcome to Vision Screening App"); } } else { Toast.makeText(mContext, "Can Not Speak", Toast.LENGTH_LONG).show(); } } public void stopTTS(){ Log.e(".....TTS", "SHUTDOWN"); tts.stop(); tts.shutdown(); } public void speakTheText(String str){ Log.e("SPEAK TEXT!!!!", "SPEAK TEXT"); tts.speak(str, TextToSpeech.QUEUE_FLUSH, null); }
}
and in my work (onCreate) I have:
controller_tts = new TextToSpeechController(getApplicationContext());
I am facing several issues:
- First of all, the onInit method is not called at all, only at the moment when I exit the current Activity.
- Anyway, after using TTS, the caster’s volume is turned off, and I can’t return the volume from the settings (only after restarting the glasses)
Am I doing something wrong? or just Google Glass does not support TTS, it’s even hard to believe it.
Any suggestion is welcome! Many thanks!:)
source share