I am developing an application that uses a third-party tts called flite. I am doing something like the vehicle says a sentence. I want to highlight every word, as they say. To do this, I managed to get word-level callbacks from tts. the workflow is similar to this - the button "speak text" is pressed. It launches tt and then sends the text to flite tts, which is in C, and has been integrated with the application. Now, from the C code, after each word, I make two callbacks for two different java actions: one for serving tts, for speaking the word second for my test java activity for highlighting the word. I successfully receive word-level callbacks in my test activity, but after that I cannot execute any user interface.
Below is the code that I execute when I receive the callback: this is a function called from C code.
private void WordCallback(int isword) {// from // callback if (isword == -1) { Log.d(LOG_TAG, "its not a word"); } else if (isword == -2) { Log.d(LOG_TAG, "yeah..its the end"); } else { Log.d(LOG_TAG, "its word no " + isword); int word = isword; Log.d(LOG_TAG, "highlightwords"); highlightwords(isword); if (isword == 4) { Log.d(LOG_TAG, "in if"); new Thread(new Runnable() { @Override public void run() { Log.d(LOG_TAG, "thread started"); try { Flitetest.this.runOnUiThread(new Runnable() { @Override public void run() { Log.d(LOG_TAG, "run on ui"); textview.setText("#" + isword); } }); Thread.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } } }).start(); } } }
FliteTest is the name of an activity. the log prints before "Thread started", but the code inside runonuithread () never executes, and there is no error either.
Also, if you write textview.settext("something") without thread and runonuithread (), it gives an error:
fatal signal 11(sigsegv) at 0x6fc64e87(code=1), thread 20292(SynthThread) .
What is the reason for this behavior?
source share