This commit is contained in:
smirgol 2023-06-29 09:29:21 +02:00 committed by GitHub
commit 4305273e3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 20 deletions

View File

@ -5,8 +5,7 @@ import threading
import os, pyaudio
import shutil
import re
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
from pocketsphinx import *
from soundfiles import SoundFiles
@ -22,12 +21,12 @@ class ProfileExecutor(threading.Thread):
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)

View File

@ -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")