Code example for TextToSpeech

Methods: isSpeakingsetPitchsetSpeechRatespeak

0
		@Override 
		protected void onPostExecute(HashMap<String, String> result) {
			progressDialog.dismiss();
 
			if (result != null) {
				Log.v(TAG, "Start speech." + mTextToSpeech.isSpeaking());
 
				Random random = new Random();
				mTextToSpeech.setPitch(random.nextFloat() + 0.75F);
				mTextToSpeech.setSpeechRate(random.nextFloat() + 0.75F);
				String text = result.get("text").replaceAll("http://t.co/\\w+", "").replaceAll("#\\w+", "");
				HashMap<String, String> params = new HashMap<String, String>();
				params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, SPEECH_TWEET_COMPLETE);
				mTextToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, params);
			} else { 
				Toast.makeText(MainActivity.this, "Tweetを取得できませんでした", Toast.LENGTH_LONG).show();
				removeDialog(ACCOUNT_DIALOG);
			} 
			super.onPostExecute(result);
		} 
Experience pair programming with AI  Get Codota for Java