Tag: 文字转语音

在CustomListview中使用TTS时出现NullPointerException

我有自定义列表视图,其中包含内容和TTS选项,而使用TTS其抛出空指针exception,Listview也没有显示我的应用程序已停止。错误显示在Logcat中。 Applicationadapter.java public class ApplicationAdapter extends ArrayAdapter implements TextToSpeech.OnInitListener{ private List items; private LayoutInflater inflator; private MainActivity activity; private ProgressDialog dialog; public TextToSpeech tts; public ImageButton btnaudioprayer; public TextView text1; ArrayAdapter adapter; public ApplicationAdapter(MainActivity context, List items){ super(context, R.layout.activity_row, items); this.items = items; inflator = LayoutInflater.from(getContext()); activity=context; } @Override public int getCount(){ return items.size(); } […]

文本到语音应用程序UI是慢机器人

在我的应用程序中,我使用的是TTS。 我有20个不同的活动,当用户向左或向右滑动时会更改这些活动。 根据活动,会说一个文字。 我正在使用单独的线程执行tts,并且主线程完成了活动选择。 但问题非常缓慢,用户界面感觉很笨拙。 当我向左或向右滑动时,一旦tts完成说出文本,活动就会发生变化,因为我正在使用单独的线程进行tts。 这是codE: TTS课程: public class textToSpeech { TextToSpeech tts=null; public textToSpeech(Context con) { tts = new TextToSpeech(con,new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if(status != TextToSpeech.ERROR) // initialization me error to nae ha { tts.setPitch(1.1f); // saw from internet tts.setSpeechRate(0.4f); // f denotes float, it actually type casts […]