#!/usr/bin/env pythonimportos,timefromsocketimport*frompocketsphinximportLiveSpeech,get_model_pathmodel_path=get_model_path()socket=socket(AF_INET,SOCK_STREAM)#cria um sockethost='HASTurtle'port=8421vel_linear=0.25vel_angular=1.5speech=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')defparseVoice(frase):iffrase=='MOVE FORWARD ':valores=' '.join([str(vel_linear),str(0)])socket.sendall(''.join([valores,'\n']).encode())eliffrase=='ROTATE LEFT ':valores=' '.join([str(0),str(-vel_angular)])socket.sendall(''.join([valores,'\n']).encode())eliffrase=='ROTATE RIGHT ':valores=' '.join([str(0),str(vel_angular)])socket.sendall(''.join([valores,'\n']).encode())eliffrase=='STOP MOVING ':socket.sendall('0 0\n'.encode())eliffrase=='STOP LISTENING ':return-1return1socket.connect(('localhost',port))print'A enviar talker ...'time.sleep(1)socket.send('talker\n'.decode())print'Enviou talker'print'Listening...'forphraseinspeech:frase=str(phrase)ifparseVoice(frase)==-1:socket.close()breakdata=socket.recv(1024).decode()printdata,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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am building a program with pocketsphinx and python this is the code i have so far:
Keyphrase list:
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
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.