Menu

Does pocketsphinx LiveSpeech lose accuracy over the time?

Help
2017-06-21
2017-06-21
  • Paulo Ferreira

    Paulo Ferreira - 2017-06-21

    I am building a program with pocketsphinx and python this is the code i have so far:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    #!/usr/bin/env python
    
    import os, time
    from socket import *
    from pocketsphinx import LiveSpeech, get_model_path
    
    model_path = get_model_path()
    socket = socket(AF_INET, SOCK_STREAM) #cria um socket
    
    host = 'HASTurtle'
    port = 8421
    vel_linear = 0.25
    vel_angular = 1.5
    
    speech = LiveSpeech(
        verbose=False,
        sampling_rate=16000,
        buffer_size=2048,
        no_search=False,
        full_utt=False,
        lm=False,
        hmm= os.path.join(model_path,'en-us'),
        #lm= '/home/paulo/PycharmProjects/VoiceRecognition/Data/TAR4858/4858.lm',
        dict = #'/home/vitor/Documentos/Univ/3_Ano/2_Semestre/Projeto/Projeto/VoiceRecognition/Data/Robot/Robot.dic',
        '/home/paulo/PycharmProjects/VoiceRecognition/Data/Robot/Robot.dic',
        kws = #'/home/vitor/Documentos/Univ/3_Ano/2_Semestre/Projeto/Projeto/VoiceRecognition/Data/Robot/Robot_Keyphrase.list'
              '/home/paulo/PycharmProjects/VoiceRecognition/Data/Robot/Robot_Keyphrase.list'
    )
    
    def parseVoice(frase):
    
        if frase == 'MOVE FORWARD ':
            valores = ' '.join([str(vel_linear),str(0)])
            socket.sendall(''.join([valores,'\n']).encode())
        elif frase == 'ROTATE LEFT ':
            valores = ' '.join([str(0),str(-vel_angular)])
            socket.sendall(''.join([valores, '\n']).encode())
        elif frase == 'ROTATE RIGHT ':
            valores = ' '.join([str(0),str(vel_angular)])
            socket.sendall(''.join([valores, '\n']).encode())
        elif frase == 'STOP MOVING ':
            socket.sendall('0 0\n'.encode())
        elif frase == 'STOP LISTENING ':
            return -1
        return 1
    
    socket.connect(('localhost',port))
    
    print 'A enviar talker ...'
    time.sleep(1)
    socket.send('talker\n'.decode())
    print 'Enviou talker'
    
    print 'Listening...'
    for phrase in speech:
        frase = str(phrase)
        if parseVoice(frase) == -1:
            socket.close()
            break
        data = socket.recv(1024).decode()
        print data,
        print 'Listening...'
    

    Keyphrase list:

    ROTATE RIGHT /1e-40/
    ROTATE LEFT /1e-35/
    MOVE FORWARD /1e-50/
    STOP MOVING /1e-10/
    STOP LISTENING /1e-20/
    

    When i first run this code and speak everything works perfect but when i give more than 5 or 6 commands i need to say the command many times until it gets recognized and sometimes it doesn't recognize at all. Should LiveSpeech be reseted or something like that?

     

    Last edit: Paulo Ferreira 2017-06-21
    • Nickolay V. Shmyrev

      Add verbose = True in arguments and track how CMN values change with time. You need to make sure that voice activity detection works and it only reacts to voice, not to the noise. If it reacts to the noise you need to raise the voice activity threshold.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.