如何在不更改页面的情况下将文本从数据库发送到 TTS
Tts.java
public void onInit(int arg0) {
Bundle dataBundle = Tts.this.getIntent().getExtras();
speech = dataBundle.getString("IMSENS");
tts.setLanguage(Locale.ENGLISH);
tts.speak(speech, TextToSpeech.QUEUE_FLUSH, null);
}
Im_SensShow.java
public class Im_SensShow extends ListActivity {
public void buttonGetClicked(View v){
Cursor cc = cursor;
Intent showSound = new Intent(Im_SensShow.this,Tts.class);
Bundle dataBundle = new Bundle();
dataBundle.putString("IMSENS",cc.getString(cc.getColumnIndexOrThrow(DBAdapter.KEY_IM_SENS)));
showSound.putExtras(dataBundle);
startActivityForResult(showSound,1);
}
我设置 tts 从 Im_SensShow.java 读取句子,当我按下 Im_SensShow.java 页面中的按钮时,该程序更改为 tts 页面并发出声音,
但实际上我希望它只发送句子而不是更改页面(留在 Im_SensShow.java 页面)
我尝试不在 Manufest 中声明 .Tts 但它强制关闭 我应该怎么办?
Tts.java
public void onInit(int arg0) {
Bundle dataBundle = Tts.this.getIntent().getExtras();
speech = dataBundle.getString("IMSENS");
tts.setLanguage(Locale.ENGLISH);
tts.speak(speech, TextToSpeech.QUEUE_FLUSH, null);
}
Im_SensShow.java
public class Im_SensShow extends ListActivity {
public void buttonGetClicked(View v){
Cursor cc = cursor;
Intent showSound = new Intent(Im_SensShow.this,Tts.class);
Bundle dataBundle = new Bundle();
dataBundle.putString("IMSENS",cc.getString(cc.getColumnIndexOrThrow(DBAdapter.KEY_IM_SENS)));
showSound.putExtras(dataBundle);
startActivityForResult(showSound,1);
}
I set tts to read a sentece from Im_SensShow.java and when I press the button in Im_SensShow.java page this progarm change to tts page and make sound
but actually I want it to send only sentence and doesn't change page (stay in Im_SensShow.java page)
I try to not declare .Tts in Manufest but it force close
What should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
tts.speak()
调用放入[onItemClick()][1]
侦听器中。您需要确保 TTS 子系统已初始化(例如,在 Im_SendShow 活动的
onCreate()
内)。Put the
tts.speak()
call in a[onItemClick()][1]
listener.You need to make sure that the TTS subsystem is already initialized (e.g. within
onCreate()
of your Im_SendShow activity).