【问题标题】:How do I add Voice Recognition to Nao Bot如何将语音识别添加到 Nao Bot
【发布时间】:2019-11-14 19:27:22
【问题描述】:

我需要一些关于 nao 机器人语音识别方面的帮助。在我的代码中,我启动了引擎,但我不知道如何将语音添加到内存然后调用它。 任何帮助都很棒。顺便说一句,这是在课堂上。

这是我的代码:

    n = "WordRecognized"
    asr = self.session.service("ALSpeechRecognition")
    asr.pause(True)
    alm = self.session.service("ALMemory")
    alm.declareEvent(n)
    asr.setAudioExpression(True)
    asr.subscribe(n)
    self.say("Started Voice Recognition")
    time.sleep(t)
    asr.unsubscribe(n)
    print(alm.getData(n))

【问题讨论】:

    标签: python voice-recognition nao-robot


    【解决方案1】:

    我不完全确定我是否理解您的问题,但总的来说,我认识到让语音检测起作用的问题。 我看到了一个单一的睡眠,这可能是它出错的地方。

    您可能需要执行以下操作:

    import time
    # get current time as start time
    t_start = time.time() 
    t_current = t_start                              
    RecognizedWords = []                    
    duration = 10                           # detecting time
    
    # if duration time has not passed
    while t_current-t_start<duration:
        recognized_words = alm.getData(n)  
        # if something is in the list (thus something was detected)
        if len(recognized_words) > 0:          
            # then we break the loop, so we stop checking for more speech.
            break                       
        else:                               # if list is empty (nothing recognized)
            t_current = time.time()   
    

    基本上,它需要在一段时间内不断检查语音,而不是休眠并查看是否检测到任何内容。 无论如何,我相信这对我有用!

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多