List of usage examples for android.speech.tts TextToSpeech LANG_MISSING_DATA
int LANG_MISSING_DATA
To view the source code for android.speech.tts TextToSpeech LANG_MISSING_DATA.
Click Source Link
From source file:Main.java
/** * get a descriptions of all the languages available as determined by * {@link TextToSpeech#isLanguageAvailable(Locale)} *//*from w w w. j av a 2s .c o m*/ public static String getLanguageAvailableDescription(TextToSpeech tts) { StringBuilder sb = new StringBuilder(); for (Locale loc : Locale.getAvailableLocales()) { int availableCheck = tts.isLanguageAvailable(loc); sb.append(loc.toString()).append(" "); switch (availableCheck) { case TextToSpeech.LANG_AVAILABLE: break; case TextToSpeech.LANG_COUNTRY_AVAILABLE: sb.append("COUNTRY_AVAILABLE"); break; case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE: sb.append("COUNTRY_VAR_AVAILABLE"); break; case TextToSpeech.LANG_MISSING_DATA: sb.append("MISSING_DATA"); break; case TextToSpeech.LANG_NOT_SUPPORTED: sb.append("NOT_SUPPORTED"); break; } sb.append(NEW_LINE); } return sb.toString(); }
From source file:com.hichinaschool.flashcards.anki.ReadText.java
public static void speak(String text, String loc) { int result = mTts.setLanguage(new Locale(loc)); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e(AnkiDroidApp.TAG, "Error loading locale " + loc.toString()); } else {/*from ww w . j a v a 2 s.com*/ if (mTts.isSpeaking()) { sTextQueue.add(new String[] { text, loc }); } else { mTts.speak(mTextToSpeak, TextToSpeech.QUEUE_FLUSH, mTtsParams); } } }
From source file:com.rsamadhan.DomainListFragment.java
/** * Called to signal the completion of the TextToSpeech engine initialization. * * @param status {@link TextToSpeech#SUCCESS} or {@link TextToSpeech#ERROR}. *//*from w w w.ja va 2 s .c o m*/ @Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = tts .setLanguage(ApplicationUtils.getSelectedLocale(PreferenceManager.getInstance(getActivity()))); tts.setPitch(0.6f); tts.setSpeechRate(0.5f); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Toast.makeText(getActivity(), getString(R.string.speech_not_supported), Toast.LENGTH_LONG).show(); } else { isTTSSuccess = true; speakOut(); } } }
From source file:com.xengar.android.englishverbs.ui.UniversalFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getArguments() != null) { verbsType = getArguments().getString(VERB_TYPE, BOTH); itemType = getArguments().getString(ITEM_TYPE, LIST); sortTYpe = getArguments().getString(SORT_TYPE, ALPHABET); }/*w w w. j a v a 2 s .com*/ // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_universal, container, false); mCustomErrorView = (CustomErrorView) view.findViewById(R.id.error); mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler); progressBar = (CircularProgressBar) view.findViewById(R.id.progressBar); mVerbs = new ArrayList<>(); // initialize Speaker tts = new TextToSpeech(getContext(), new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(Locale.US); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { if (LOG) { Log.e("TTS", "This Language is not supported"); } } } else { if (LOG) { Log.e("TTS", "Initilization Failed!"); } } } }); mAdapter = new VerbAdapter(mVerbs, itemType, tts); return view; }
From source file:com.nbplus.vbroadlauncher.BaseActivity.java
@Override public void onInit(int status) { Log.d(TAG, "> TTS onInit()"); LauncherSettings.getInstance(this).setIsCheckedTTSEngine(true); if (status != TextToSpeech.SUCCESS) { Log.e(TAG, String.format("TextToSpeechManager.onInit(%d) fail!", status)); Log.d(TAG, " ??.... ? ??..."); if (mcheckText2SpeechLister != null) { mcheckText2SpeechLister.onCheckResult(null); if (mText2Speech != null) mText2Speech.shutdown(); mText2Speech = null;// w ww. j a va2s . com } showText2SpeechAlertDialog(); } else { int result = mText2Speech.setLanguage(Locale.KOREA); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e(TAG, String.format("TextToSpeech.setLanguage(%s) fail!", Locale.KOREA.getDisplayName())); Log.d(TAG, " ??.... ? ??..."); if (mcheckText2SpeechLister != null) { mcheckText2SpeechLister.onCheckResult(null); if (mText2Speech != null) mText2Speech.shutdown(); mText2Speech = null; } showText2SpeechAlertDialog(); } else { if (mcheckText2SpeechLister != null) { mcheckText2SpeechLister.onCheckResult(mText2Speech); } else { if (mcheckText2SpeechLister != null) { mcheckText2SpeechLister.onCheckResult(null); if (mText2Speech != null) mText2Speech.shutdown(); mText2Speech = null; } } } } }
From source file:com.example.robert.bluetoothnew.BluetoothChatFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);//from w ww .j ava2s . c om // Get local Bluetooth adapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); initSingleTonTemp(); // If the adapter is null, then Bluetooth is not supported intiCallWeb(); toWebPosition(); if (mBluetoothAdapter == null) { FragmentActivity activity = getActivity(); Toast.makeText(activity, "Bluetooth is not available", Toast.LENGTH_LONG).show(); activity.finish(); } // No bluetooth service tts = new TextToSpeech(getActivity(), new TextToSpeech.OnInitListener() { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public void onInit(int status) { Log.v("abasdasd", "status 123"); if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(Locale.TAIWAN); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e("TTS", "This Language is not supported"); } else { } } else { Log.e("TTS", "Initilization Failed!"); } } }); }
From source file:com.hichinaschool.flashcards.anki.ReadText.java
public static void initializeTts(Context context) { mReviewer = context;/*from w ww . jav a 2s. co m*/ mTts = new TextToSpeech(context, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { // TODO: check if properly initialized (does not work yet) if (status != TextToSpeech.SUCCESS) { int result = mTts.setLanguage(Locale.US); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { } else { Log.e(AnkiDroidApp.TAG, "TTS initialized and set to US"); } } else { Log.e(AnkiDroidApp.TAG, "Initialization of TTS failed"); } AnkiDroidApp.getCompat().setTtsOnUtteranceProgressListener(mTts); } }); mTtsParams = new HashMap<String, String>(); mTtsParams.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "stringId"); }
From source file:net.bible.service.device.speak.TextToSpeechController.java
@Override public void onInit(int status) { Log.d(TAG, "Tts initialised"); boolean isOk = false; // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR. if (mTts != null && status == TextToSpeech.SUCCESS) { Log.d(TAG, "Tts initialisation succeeded"); boolean localeOK = false; Locale locale = null;//from w ww .j av a 2s.c o m for (int i = 0; i < localePreferenceList.size() && !localeOK; i++) { locale = localePreferenceList.get(i); Log.d(TAG, "Checking for locale:" + locale); int result = mTts.setLanguage(locale); localeOK = ((result != TextToSpeech.LANG_MISSING_DATA) && (result != TextToSpeech.LANG_NOT_SUPPORTED)); if (localeOK) { Log.d(TAG, "Successful locale:" + locale); currentLocale = locale; } } if (!localeOK) { Log.e(TAG, "TTS missing or not supported"); // Language data is missing or the language is not supported. ttsLanguageSupport.addUnsupportedLocale(locale); showError(R.string.tts_lang_not_available); } else { // The TTS engine has been successfully initialized. ttsLanguageSupport.addSupportedLocale(locale); int ok = mTts.setOnUtteranceCompletedListener(this); if (ok == TextToSpeech.ERROR) { Log.e(TAG, "Error registering onUtteranceCompletedListener"); } else { // everything seems to have succeeded if we get here isOk = true; // say the text startSpeaking(); // add event listener to stop on call stopIfPhoneCall(); } } } else { Log.d(TAG, "Tts initialisation failed"); // Initialization failed. showError(R.string.error_occurred); } if (!isOk) { shutdown(); } }
From source file:com.bellman.bible.service.device.speak.TextToSpeechController.java
@Override public void onInit(int status) { Log.d(TAG, "Tts initialised"); boolean isOk = false; // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR. if (mTts != null && status == TextToSpeech.SUCCESS) { Log.d(TAG, "Tts initialisation succeeded"); boolean localeOK = false; Locale locale = null;//from w w w. j a va 2s .co m for (int i = 0; i < localePreferenceList.size() && !localeOK; i++) { locale = localePreferenceList.get(i); Log.d(TAG, "Checking for locale:" + locale); int result = mTts.setLanguage(locale); localeOK = ((result != TextToSpeech.LANG_MISSING_DATA) && (result != TextToSpeech.LANG_NOT_SUPPORTED)); if (localeOK) { Log.d(TAG, "Successful locale:" + locale); currentLocale = locale; } } if (!localeOK) { Log.e(TAG, "TTS missing or not supported"); // Language data is missing or the language is not supported. ttsLanguageSupport.addUnsupportedLocale(locale); showError(R.string.tts_lang_not_available, new Exception("Tts missing or not supported")); } else { // The TTS engine has been successfully initialized. ttsLanguageSupport.addSupportedLocale(locale); int ok = mTts.setOnUtteranceCompletedListener(this); if (ok == TextToSpeech.ERROR) { Log.e(TAG, "Error registering onUtteranceCompletedListener"); } else { // everything seems to have succeeded if we get here isOk = true; // say the text startSpeaking(); // add event listener to stop on call stopIfPhoneCall(); } } } else { Log.d(TAG, "Tts initialisation failed"); // Initialization failed. showError(R.string.error_occurred, new Exception("Tts Initialisation failed")); } if (!isOk) { shutdown(); } }
From source file:com.microsoft.AzureIntelligentServicesExample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this._logText = (EditText) findViewById(R.id.editText1); this._startButton = (Button) findViewById(R.id.button1); tts = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() { @Override/* ww w. j a va 2 s .c o m*/ public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(Locale.US); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e("TTS", "This Language is not supported"); Intent installIntent = new Intent(); installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); startActivity(installIntent); } } else { Log.e("TTS", "Initilization Failed!"); } } }); ImageView sendBtn = (ImageView) findViewById(R.id.sendBtn); final EditText message = (EditText) findViewById(R.id.message); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { _logText.append("ME : " + message.getText().toString() + "\n"); speakOut(message.getText().toString()); message.setText(""); } }); if (getString(R.string.primaryKey).startsWith("Please")) { new AlertDialog.Builder(this).setTitle(getString(R.string.add_subscription_key_tip_title)) .setMessage(getString(R.string.add_subscription_key_tip)).setCancelable(false).show(); } // setup the buttons final MainActivity This = this; this._startButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { This.StartButton_Click(arg0); } }); }