【问题标题】:Android: SpeechRecognizer beepAndroid:语音识别器哔声
【发布时间】:2013-06-07 13:13:14
【问题描述】:

在 Jelly Bean SpeecRecognizer 中确定有哔声...我希望在旧版本中具有相同的声音(或我选择的声音)。

我现在就是这样

                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,我需要在 SpeechRecognizer 侦听器中的哪个位置放置此哔声?

我想告诉我,我不想在录制时播放哔声,因为它会破坏我的识别!

如果有人能找到我,JB 的哔哔声会很棒:)

【问题讨论】:

    标签: android speech-recognition beep


    【解决方案1】:

    你可以把它放在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);
            }
    
        }
    

    【讨论】:

    • 谢谢!但是onReadyForSpeech 不是我需要的地方,振动也不是我需要的……我的方式比 onReadyForSpeech 好……我在上面说过,我不想在录制时发出哔声……而 onReadyForSpeech 是录制时间!
    • 是的,很遗憾我已经为我自己的应用程序 Carma.RSenApps.com 做了很多研究,我发现振动解决方案是最好的,如果有任何变化,请告诉我:)
    • 好的,我会告诉你...直到 7 月底,我们将开始更新我们的应用程序,所以我有一些想法,我们会尝试它们......如果它们有效,我会让你知道的:p
    猜你喜欢
    • 2020-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多