Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions profileexecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import os, pyaudio
import shutil
import re
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
from pocketsphinx import *
from soundfiles import SoundFiles


Expand All @@ -22,12 +21,12 @@ def __init__(self, p_profile = None, p_parent = None):
self.m_listening = False
self.m_cmdThreads = {}

self.m_config = Decoder.default_config()
self.m_config.set_string('-hmm', os.path.join('model', 'en-us/en-us'))
self.m_config.set_string('-dict', os.path.join('model', 'en-us/cmudict-en-us.dict'))
self.m_config.set_string('-kws', 'command.list')
# you usually don't want all this info stuff as a regular user. it just covers up init messages
self.m_config.set_string('-logfn', '/dev/null')
self.m_config = Config(
hmm=os.path.join('model', 'en-us/en-us'),
dict=os.path.join('model', 'en-us/cmudict-en-us.dict'),
kws='command.list',
logfn='/dev/null'
)

self.m_pyaudio = pyaudio.PyAudio()
self.m_stream = self.m_pyaudio.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True)
Expand Down
24 changes: 12 additions & 12 deletions set_kws_threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# keyphrases found in kwlist
WORDS = []
# test case containing multiple occurances
# test case containing multiple occurances
# of words to be used as training audio
TEST_CASE = []
# Threshold values
Expand All @@ -36,7 +36,7 @@ def preprocess_files(dic_path, kwlist_path):
with open(dic_path) as _f:
_content = _f.readlines()
_content = [x.strip() for x in _content]

with open(kwlist_path) as _f:
WORDS = _f.readlines()
WORDS = [x.strip()[:x.strip().rfind(' ')] for x in WORDS]
Expand Down Expand Up @@ -188,7 +188,7 @@ def actual_tuning(dic_path, kwlist_path, _z):
_previous_missed.extend(_missed)
_previous_fa = []
_previous_fa.extend(_fa)

_missed, _fa = process_threshold(kws_analysis(dic_path, kwlist_path))

if _z == 1:
Expand Down Expand Up @@ -224,14 +224,14 @@ def kws_analysis(dic, kwlist):
modeldir = "/usr/local/share/pocketsphinx/model/"

# Create a decoder with certain model
config = Decoder.default_config()
config.set_string('-hmm', os.path.join(modeldir, 'en-us/en-us'))
config.set_string('-dict', dic)
config.set_string('-kws', kwlist)
config.set_string('-dither', "no")
config.set_string('-logfn', '/dev/null')
config.set_string('-featparams', os.path.join(os.path.join(modeldir,
'en-us/en-us'), "feat.params"))
config = Config(
hmm=os.path.join(modeldir, 'en-us/en-us'),
dict=dic,
kws=kwlist,
dither="no",
featparams=os.path.join(os.path.join(modeldir, 'en-us/en-us'), "feat.params"),
logfn='/dev/null'
)

stream = open(OUTPUT_FILENAME, "rb")

Expand Down Expand Up @@ -291,7 +291,7 @@ def process_threshold(analysis_result):
missed[position_original][1] += 1
print ('Missed ', val)
return missed, false_alarms

if __name__ == '__main__':
DIC_FILE = "/home/pankaj/catkin_ws/src/pocketsphinx/demo/voice_cmd.dic"
KWLIST_FILE = "/home/pankaj/catkin_ws/src/pocketsphinx/demo/automated.kwlist"
Expand Down