【问题标题】:SpeechRecognizer - time limitSpeechRecognizer - 时间限制
【发布时间】:2012-06-20 03:28:53
【问题描述】:

我将SppechRecognizer 用于语音识别应用程序。它工作正常。我的要求是我想在 1 秒或 2 秒后停止收听语音。如何实现?

【问题讨论】:

    标签: android speech-recognition voice-recognition


    【解决方案1】:

    1 或 2 秒似乎不是很多时间,但如果你想设置时间限制,你可能不得不将其设置为线程。 Android 有一些默认附加功能可以设置语音输入的最小长度和用户停止说话后的最大数量,但没有设置语音输入的最大时间长度。

    最好的办法是使用某种计时器,比如CountDownTimer

     yourSpeechListener.startListening(yourRecognizerIntent);
     new CountDownTimer(2000, 1000) {
    
         public void onTick(long millisUntilFinished) {
             //do nothing, just let it tick
         }
    
         public void onFinish() {
             yourSpeechListener.stopListening();
         }
      }.start();
    

    我还鼓励您查看可用于RecognizerIntent 的附加功能,看看是否有更适合您的需求。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-12
    • 2014-03-27
    • 1970-01-01
    相关资源
    最近更新 更多