Ok在果冻豆语音识别器有哔哔声…我想在旧版本中有相同的声音(或我选择的声音)
我现在就是这样做的
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion < android.os.Build.VERSION_CODES.JELLY_BEAN){
//prepare beep
beep.start();
}
//prepare intent
sr.startListening(intent);
但是在哔声和聆听之间还有一段时间…在哪里,在语音识别器的监听器,我需要把这个蜂鸣声开始如果低于jb ?
我想告诉你,我不想在录音时播放哔哔声,因为它会干扰我的识别!
如果有人能找到我JB的哔哔声会很棒的:)
你可以把它放在onReadyForSpeech(如果你实现了RecogntionListener)
public class MySpeechRecognizer implements RecognitionListener {
public void initialize()
{
//... other SpeechRecognizer initialization
mSpeechRecognizer.setRecognitionListener(this);
}
@Override
public void onReadyForSpeech(Bundle params) {
final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
tg.startTone(ToneGenerator.TONE_PROP_BEEP);
}
//... other required methods of RecognitionListener
}
唯一的问题是,蜂鸣声会导致识别开始,所以如果在onError中得到错误7(没有结果),则需要重新启动识别。
或者,我已经用振动的解决方案(除了使用蓝牙耳机时)而不是蜂鸣声,因为振动不会被语音识别检测到。
@Override
public void onReadyForSpeech(Bundle params) {
Log.d("SpeechRecognizer", "Ready");
if (beepOnReady && !hasBeeped) {
Log.d("SpeechRecognizer", "Beeping");
hasBeeped = true;
if (beepOnBluetooth) {
final ToneGenerator tg = new ToneGenerator(6, 100);
tg.startTone(ToneGenerator.TONE_PROP_BEEP);
}
else
{
Vibrator vibe = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE) ;
vibe.vibrate(50);
}
}