Search code examples
speech-recognitionpocketsphinx

How to tune keyphrase thresholds with pocketsphinx-python


I need to develop a speech recognition software so i am using Pocketsphinx with Python. I want to recognize just a few words so i am using a keyphrase list with thresholds in order to reject out of grammar words. I have this code so far:

#!/usr/bin/env python

import os
from pocketsphinx import LiveSpeech, get_model_path

model_path = get_model_path()



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',
    dic = '/home/paulo/PycharmProjects/VoiceRecognition/Data/TAR4858/4858.dic',
    kws = '/home/paulo/PycharmProjects/VoiceRecognition/Data/TAR4858/keyphrase.list'
)

for phrase in speech:
    frase = str(phrase)
    print frase

This is my dictionary:

BROWSER B R AW Z ER
COMPUTER    K AH M P Y UW T ER
HELLO   HH AH L OW
HELLO(2)    HH EH L OW
MUSIC   M Y UW Z IH K
OFF AO F
ON  AA N
ON(2)   AO N
OPEN    OW P AH N
TURN    T ER N

Here is my keyphrase.list:

OPEN BROWSER /1e-1/
TURN ON MUSIC /1e-20/
TURN OFF MUSIC /1e-20/
TURN OFF COMPUTER /1e-25/
HELLO COMPUTER /1e-25/

This is working but i saw on cmu sphinx website about keyword lists that i need to tune those thresholds with the command

 pocketsphinx_continuous -infile <your_file.wav> -keyphrase <your keyphrase> \
  -kws_threshold <your_threshold> -time yes

But how can i do it with the pocketsphinx installed for python?


Solution

  • Install pocketsphinx for pocketsphinx_continuous, not just pocketsphinx-python.