@Override public void onCreate(File file) { super.onCreate(file); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { tts.synthesizeToFile(text, null, file,null); }else { tts.synthesizeToFile(text, null, file.getAbsolutePath()); } Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+file.getAbsolutePath())); shareIntent.setType("audio/*"); MainActivity.activity.startActivity(Intent.createChooser(shareIntent, MainActivity.activity.getResources().getText(R.string.send_to))); }
public void onClickSalvar(View view) { String s = tMsg.getText().toString(); // Sintetiza a voz para arquivo File file = SDCardUtils.getPublicFile("arquivo-voz.wav", Environment.DIRECTORY_MUSIC); HashMap<String, String> params = new HashMap<String,String>(); tts.synthesizeToFile(s, params, file.getAbsolutePath()); toast("Voz salva em arquivo: " + file); }
file.setWritable(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { tts.synthesizeToFile(text, null, file, null); } else { tts.synthesizeToFile(text, null, file.getAbsolutePath());
TextToSpeech mTextToSpeech = new TextToSpeech(this,new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { // TODO Auto-generated method stub if(status == TextToSpeech.SUCCESS) { // set language int supported = mTextToSpeech.setLanguage(Locale.US); if((supported != TextToSpeech.LANG_AVAILABLE)&&(supported != TextToSpeech.LANG_COUNTRY_AVAILABLE)) { displayToast("dont support current language"); } } } }); // start to speak mTextToSpeech.speak("A for Apple", TextToSpeech.QUEUE_FLUSH, null); // store your voice to file int r = mTextToSpeech.synthesizeToFile(mEditText.getText().toString(), null, "/mnt/sdcard/speak.wav"); if(r == TextToSpeech.SUCCESS) displayToast("save success!");
String tempDestFile = appTmpPath.getAbsolutePath() + "/" + tempFilename; mTts.synthesizeToFile(speakTextTxt, myHashRender, tempDestFile);