我正在使用 IVONA 库进行文字转语音,一切正常,但我面临一个问题
在键盘空格键按下我需要在空格之前说出书面单词,当用户缓慢键入时这也可以正常工作,但是当用户快速键入单词时 ivona 崩溃并给我这个错误
libc: Fatal signal 11 (SIGSEGV) at 0x00000080 (code=1), thread 15441 (Thread-2170)
libc: Send stop signal to pid:15384 in void debuggerd_signal_handler(int, siginfo_t*, void*)
这是我的 ivona 代码
public void readWord_Sentence(final String word) {
new Thread() {
@Override
public void run() {
try {
int sampleRate = initStreamer(word, false);
if (sampleRate == -1) return;
int numSamples = sampleRate / 10;
if (mStreamer != null) {
JIvonaWave w;
while ((w = mStreamer.synth(numSamples)) != null) {
if (mTrack == null) {
mTrack = createAudioTrack(sampleRate);
}
short[] samples = w.getSamples();
mTrack.write(samples, 0, samples.length);
mTrack.play();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
stopWord_Sentence();
}// end finally
}
}.start();
}
/**
* Force stop word or sentences
*/
public synchronized void stopWord_Sentence() {
if (mStreamer != null) {
try {
synchronized (mStreamer) {
mStreamer.stop();
mStreamer = null;
}
} catch (SystemException e) {
e.printStackTrace();
} catch (InternalException e) {
e.printStackTrace();
} catch (RuntimeException e) {
e.printStackTrace();
}
}
if (mTrack != null) {
try {
mTrack.flush();
mTrack.stop();
mTrack.release();
mTrack = null;
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (RuntimeException e) {
e.printStackTrace();
}
}
}
我试图评论所有代码,并在这一行发生错误mStreamer.synth(numSamples)
我正在为 ivona 使用 .so 文件,错误在libtts_engine.so
文件中
编辑
此代码在键盘space
单击方法中
Thread thread = new Thread() {
@Override
public void run() {
super.run();
if (!readingWordOrSentence.trim().equals("")) {
executor.execute(() -> keyboardTextReader.readWord_Sentence(readingWordOrSentence.trim()));
}
}
};
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();
上面的代码在里面readWord_Sentence()
读取单词。