我有一个语音识别系统,这就是listen(button)
功能
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jButton1.setIcon( loading_icon );
microphone.startRecording()
jButton1.setIcon( speak_icon );
System.out.println("Start speaking. Press Ctrl-C to quit.\n");
result = recognizer.recognize();
if (result != null) {
String bestfinalnofiller = result.getBestFinalResultNoFiller();
String hypothesis = result.getBestPronunciationResult();
String getresult = result.getBestResultNoFiller();
System.out.println("You said: " + bestfinalnofiller + '\n');
System.out.println("You said: " + hypothesis + '\n');
System.out.println("You said: " + getresult + '\n');
} else {
}
}
我的结果将是:按钮图标保持不变,并在工作完成后更改系统在工作进行时打印字符串"start speaking..."
recognizer.recognize()
功能:
public Result recognize(String referenceText) throws IllegalStateException {
Result result = null;
checkState(State.READY);
try {
setState(State.RECOGNIZING);
result = decoder.decode(referenceText);
} finally {
setState(State.READY);
}
return result;
}
我试图添加:
SwingUtilities.invokeLater
但没有用,请帮助我,我想让按钮在计算时更改它的图标图像......