You are not logged in.
Pages: 1
Hello I was just trying to install and run voximp. I have followed each step from
http://ardoris.wordpress.com/2008/08/09 … ol-voximp/
here is voximpconf.py. I did run voximp -c and the file voximpconf.pyc does exist
languagemodel = '9882' #set this to something sensible
keycommand = {
'RIGHT': "super+Right", #move one tag to the right
'LEFT': "super+Left", #move one tag to the left
'TERMINAL': "ctrl+grave", #spawn the terminal
'CLOSE': "alt+F4", #close window
'ENTER': "Return",
'SAVE': "ctrl+s",
'NEW': "ctrl+n",
'TAB': "ctrl+Tab", #for seeing next firefox tab
'BACKSPACE': "BackSpace",
'CUT': "ctrl+x",
'COPY': "ctrl+c",
'PASTE': "ctrl+v"
}
for letter in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
keycommand[letter] = letter.lower() #add all the letters - yes this is a true python file, you can do w/e you want in here
programcommand = {
'FIREFOX': "firefox",
'NOTEPAD': "medit",
'GOOGLE': "firefox www.google.com", #open google in a new tab in firefox
'HIBERNATE': "sudo hibernate",
'PLAY': "xmms2 play",
'STOP': "xmms2 stop"
}
mousecommand = {
'CLICK': '1', #leftclick
'RIGHTCLICK': '3' #rightclick
}
progswithargs = {
'ALERT': "notify-send" #just to demonstrate with arguments
}
confirm = [ #anything listed here produces a confirm dialog before being executed
'HIBERNATE'
]Here is /usr/bin/voximp
#!/usr/bin/env python2
# Copyright (c) 2008 Ben Duffield
# Licensing - no idea
# Probably w/e sphinx is, think it's MIT
# Be nice!
#######
#REQUIRES:
# gstreamer
# pygtk
# pocketsphinx
# xdotool
#########
import pygtk
pygtk.require('2.0')
import gtk
import gobject
import pygst
pygst.require('0.10')
gobject.threads_init()
import gst
from subprocess import Popen
import os
import sys
import getopt
config_dir = os.path.join(os.path.expanduser("~"), '.config/voximp/')
try:
os.makedirs(config_dir)
except:
pass
sys.path.append(config_dir)
from voximpconf import *
language_file = os.path.join(config_dir, str(languagemodel))
config = {
'hmm': '/usr/share/pocketsphinx/model/hmm/wsj1',
'lm': '%s.lm' % language_file,
'dict': '%s.dic' % language_file
}
class Voximp(object):
dial = None
def __init__(self):
self.init_gst()
self.pipeline.set_state(gst.STATE_PLAYING)
def init_gst(self):
self.pipeline = gst.parse_launch('alsasrc device="hw:0,1" ! audioconvert ! audioresample '
+ '! vader name=vad auto-threshold=true '
+ '! pocketsphinx name=asr ! fakesink')
asr = self.pipeline.get_by_name('asr')
asr.connect('partial_result', self.asr_partial_result)
asr.connect('result', self.asr_result)
asr.set_property('lm', config['lm'])
asr.set_property('dict', config['dict'])
asr.set_property('configured', True)
bus = self.pipeline.get_bus()
bus.add_signal_watch()
bus.connect('message::application', self.application_message)
self.pipeline.set_state(gst.STATE_PAUSED)
def asr_partial_result(self, asr, text, uttid):
struct = gst.Structure('partial_result')
struct.set_value('hyp', text)
struct.set_value('uttid', uttid)
asr.post_message(gst.message_new_application(asr, struct))
def asr_result(self, asr, text, uttid):
struct = gst.Structure('result')
struct.set_value('hyp', text)
struct.set_value('uttid', uttid)
asr.post_message(gst.message_new_application(asr, struct))
def application_message(self, bus, msg):
msgtype = msg.structure.get_name()
if msgtype == 'partial_result':
self.partial_result(msg.structure['hyp'], msg.structure['uttid'])
elif msgtype == 'result':
self.final_result(msg.structure['hyp'], msg.structure['uttid'])
#self.pipeline.set_state(gst.STATE_PAUSED)
#self.button.set_active(False)
def partial_result(self, hyp, uttid):
print "partial: %s" % hyp
def final_result(self, hyp, uttid):
print "final: %s" % hyp
prog = ''
command = None
if self.dial is not None:
if hyp == 'YES':
self.dial.response(gtk.RESPONSE_YES)
else:
self.dial.response(gtk.RESPONSE_NO)
elif hyp in programcommand:
prog = programcommand[hyp]
command = hyp
elif hyp in keycommand:
prog = "xdotool key ``%s''" % keycommand[hyp]
command = hyp
elif hyp in mousecommand:
prog = "xdotool click %s" % mousecommand[hyp]
command = hyp
else:
values = hyp.split(' ')
if len(values) <= 1:
return
if values[0] in progswithargs:
prog = progswithargs[values[0]] + ' ' + ' '.join(values)
command = values[0]
else:
for value in values:
self.final_result(value, 0)
if prog:
print "command is %s" % command
if command in confirm:
self.confirm(prog)
else:
p = Popen(prog, shell=True)
def confirm(self, prog):
print "Confirming %s" % prog
self.dial = gtk.MessageDialog(message_format = "Confirm?", type=gtk.MESSAGE_QUESTION)
self.dial.format_secondary_markup("Say <b><i>yes</i></b> or <b><i>no</i></b>")
self.dial.prog = prog
self.dial.show_all()
self.dial.connect("response", self.confirmCallback)
def confirmCallback(self, dialog, response_id):
print "callback called back"
if response_id == gtk.RESPONSE_YES:
p = Popen(dialog.prog, shell=True)
self.dial.destroy()
self.dial = None
versionNumber = '0.0.1'
usageInfo = '''Usage: voximp [options]
Options:
-v, --version show program version and exit
-h, --help show this help message and exit
-c, --corpus create a corpus.txt in current directory - used for generating language model files
'''
def usage():
print "Voximp version %s" % versionNumber
print usageInfo
def version():
print "Version %s" % versionNumber
def corpus():
words = []
words.extend(keycommand.keys())
words.extend(programcommand.keys())
words.extend(mousecommand.keys())
words.extend(progswithargs.keys())
corpusText = "\n".join(words)
filename = os.path.join(os.getcwd(), 'corpus.txt')
print "Saving to %s" % filename
corp = open(filename, 'w')
corp.write(corpusText)
corp.flush()
corp.close()
print "Corpus saved"
print "Now visit http://www.speech.cs.cmu.edu/tools/lmtool.html"
print " ==> choose the corpus file, click COMPILE KNOWLEDGE BASE"
print " ==> save the three files to ~/.config/voximp/"
print " ==> edit ~/.config/voximp/voximpconf.py and set the languagemodel string to the appropriate value \n\t- e.g. if the files are named 4766.dic, 4766.lm and 4766.sent, set languagemodel = '4766'"
if __name__ == '__main__':
try:
opts, args = getopt.getopt(sys.argv[1:], "hcv", ["help", "corpus", "version"])
except getopt.GetoptError:
print "error"
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt in ("-c", "--corpus"):
corpus()
sys.exit()
elif opt in ("-v", "--version"):
version()
sys.exit()
app = Voximp()
gtk.main()here is my hardware
**** List of CAPTURE Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC268 Analog [ALC268 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Microphone [Logitech USB Microphone], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0I have also unmuted and turned up the mic in alsa mixer.
Here is the output of voximp
** Message: pygobject_register_sinkfunc is deprecated (GstObject)
INFO: cmd_ln.c(691): Parsing command line:
gst-pocketsphinx \
-samprate 8000 \
-cmn prior \
-fwdflat no \
-bestpath no \
-maxhmmpf 2000 \
-maxwpf 20
Current configuration:
[NAME] [DEFLT] [VALUE]
-agc none none
-agcthresh 2.0 2.000000e+00
-alpha 0.97 9.700000e-01
-ascale 20.0 2.000000e+01
-aw 1 1
-backtrace no no
-beam 1e-48 1.000000e-48
-bestpath yes no
-bestpathlw 9.5 9.500000e+00
-bghist no no
-ceplen 13 13
-cmn current prior
-cmninit 8.0 8.0
-compallsen no no
-debug 0
-dict
-dictcase no no
-dither no no
-doublebw no no
-ds 1 1
-fdict
-feat 1s_c_d_dd 1s_c_d_dd
-featparams
-fillprob 1e-8 1.000000e-08
-frate 100 100
-fsg
-fsgusealtpron yes yes
-fsgusefiller yes yes
-fwdflat yes no
-fwdflatbeam 1e-64 1.000000e-64
-fwdflatefwid 4 4
-fwdflatlw 8.5 8.500000e+00
-fwdflatsfwin 25 25
-fwdflatwbeam 7e-29 7.000000e-29
-fwdtree yes yes
-hmm
-input_endian little little
-jsgf
-kdmaxbbi -1 -1
-kdmaxdepth 0 0
-kdtree
-latsize 5000 5000
-lda
-ldadim 0 0
-lextreedump 0 0
-lifter 0 0
-lm
-lmctl
-lmname default default
-logbase 1.0001 1.000100e+00
-logfn
-logspec no no
-lowerf 133.33334 1.333333e+02
-lpbeam 1e-40 1.000000e-40
-lponlybeam 7e-29 7.000000e-29
-lw 6.5 6.500000e+00
-maxhmmpf -1 2000
-maxnewoov 20 20
-maxwpf -1 20
-mdef
-mean
-mfclogdir
-min_endfr 0 0
-mixw
-mixwfloor 0.0000001 1.000000e-07
-mllr
-mmap yes yes
-ncep 13 13
-nfft 512 512
-nfilt 40 40
-nwpen 1.0 1.000000e+00
-pbeam 1e-48 1.000000e-48
-pip 1.0 1.000000e+00
-pl_beam 1e-10 1.000000e-10
-pl_pbeam 1e-5 1.000000e-05
-pl_window 0 0
-rawlogdir
-remove_dc no no
-round_filters yes yes
-samprate 16000 8.000000e+03
-seed -1 -1
-sendump
-senlogdir
-senmgau
-silprob 0.005 5.000000e-03
-smoothspec no no
-svspec
-tmat
-tmatfloor 0.0001 1.000000e-04
-topn 4 4
-topn_beam 0 0
-toprule
-transform legacy legacy
-unit_area yes yes
-upperf 6855.4976 6.855498e+03
-usewdphones no no
-uw 1.0 1.000000e+00
-var
-varfloor 0.0001 1.000000e-04
-varnorm no no
-verbose no no
-warp_params
-warp_type inverse_linear inverse_linear
-wbeam 7e-29 7.000000e-29
-wip 0.65 6.500000e-01
-wlen 0.025625 2.562500e-02
INFO: cmd_ln.c(691): Parsing command line:
\
-nfilt 20 \
-lowerf 1 \
-upperf 4000 \
-wlen 0.025 \
-transform dct \
-round_filters no \
-remove_dc yes \
-svspec 0-12/13-25/26-38 \
-feat 1s_c_d_dd \
-agc none \
-cmn current \
-cmninit 56,-3,1 \
-varnorm no
Current configuration:
[NAME] [DEFLT] [VALUE]
-agc none none
-agcthresh 2.0 2.000000e+00
-alpha 0.97 9.700000e-01
-ceplen 13 13
-cmn current current
-cmninit 8.0 56,-3,1
-dither no no
-doublebw no no
-feat 1s_c_d_dd 1s_c_d_dd
-frate 100 100
-input_endian little little
-lda
-ldadim 0 0
-lifter 0 0
-logspec no no
-lowerf 133.33334 1.000000e+00
-ncep 13 13
-nfft 512 512
-nfilt 40 20
-remove_dc no yes
-round_filters yes no
-samprate 16000 8.000000e+03
-seed -1 -1
-smoothspec no no
-svspec 0-12/13-25/26-38
-transform legacy dct
-unit_area yes yes
-upperf 6855.4976 4.000000e+03
-varnorm no no
-verbose no no
-warp_params
-warp_type inverse_linear inverse_linear
-wlen 0.025625 2.500000e-02
INFO: acmod.c(246): Parsed model-specific feature parameters from /usr/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k/feat.params
INFO: feat.c(713): Initializing feature stream to type: '1s_c_d_dd', ceplen=13, CMN='current', VARNORM='no', AGC='none'
INFO: cmn.c(142): mean[0]= 12.00, mean[1..12]= 0.0
INFO: acmod.c(167): Using subvector specification 0-12/13-25/26-38
INFO: mdef.c(517): Reading model definition: /usr/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k/mdef
INFO: mdef.c(528): Found byte-order mark BMDF, assuming this is a binary mdef file
INFO: bin_mdef.c(336): Reading binary model definition: /usr/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k/mdef
INFO: bin_mdef.c(513): 50 CI-phone, 143047 CD-phone, 3 emitstate/phone, 150 CI-sen, 5150 Sen, 27135 Sen-Seq
INFO: tmat.c(205): Reading HMM transition probability matrices: /usr/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k/transition_matrices
INFO: acmod.c(121): Attempting to use SCHMM computation module
INFO: ms_gauden.c(198): Reading mixture gaussian parameter: /usr/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k/means
INFO: ms_gauden.c(292): 1 codebook, 3 feature, size:
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(198): Reading mixture gaussian parameter: /usr/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k/variances
INFO: ms_gauden.c(292): 1 codebook, 3 feature, size:
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(294): 256x13
INFO: ms_gauden.c(354): 0 variance values floored
INFO: s2_semi_mgau.c(903): Loading senones from dump file /usr/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k/sendump
INFO: s2_semi_mgau.c(927): BEGIN FILE FORMAT DESCRIPTION
INFO: s2_semi_mgau.c(1022): Using memory-mapped I/O for senones
INFO: s2_semi_mgau.c(1296): Maximum top-N: 4 Top-N beams: 0 0 0
INFO: dict.c(317): Allocating 4158 * 32 bytes (129 KiB) for word entries
INFO: dict.c(332): Reading main dictionary: /home/tron/.config/voximp/9882.dic
INFO: dict.c(211): Allocated 0 KiB for strings, 0 KiB for phones
INFO: dict.c(335): 51 words read
INFO: dict.c(341): Reading filler dictionary: /usr/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k/noisedict
INFO: dict.c(211): Allocated 0 KiB for strings, 0 KiB for phones
INFO: dict.c(344): 11 words read
INFO: dict2pid.c(396): Building PID tables for dictionary
INFO: dict2pid.c(404): Allocating 50^3 * 2 bytes (244 KiB) for word-initial triphones
INFO: dict2pid.c(131): Allocated 60400 bytes (58 KiB) for word-final triphones
INFO: dict2pid.c(195): Allocated 60400 bytes (58 KiB) for single-phone word triphones
INFO: ngram_model_arpa.c(477): ngrams 1=49, 2=94, 3=47
INFO: ngram_model_arpa.c(135): Reading unigrams
INFO: ngram_model_arpa.c(516): 49 = #unigrams created
INFO: ngram_model_arpa.c(195): Reading bigrams
INFO: ngram_model_arpa.c(533): 94 = #bigrams created
INFO: ngram_model_arpa.c(534): 3 = #prob2 entries
INFO: ngram_model_arpa.c(542): 3 = #bo_wt2 entries
INFO: ngram_model_arpa.c(292): Reading trigrams
INFO: ngram_model_arpa.c(555): 47 = #trigrams created
INFO: ngram_model_arpa.c(556): 2 = #prob3 entries
INFO: ngram_search_fwdtree.c(99): 41 unique initial diphones
INFO: ngram_search_fwdtree.c(147): 0 root, 0 non-root channels, 17 single-phone words
INFO: ngram_search_fwdtree.c(186): Creating search tree
INFO: ngram_search_fwdtree.c(191): before: 0 root, 0 non-root channels, 17 single-phone words
INFO: ngram_search_fwdtree.c(326): after: max nonroot chan increased to 191
INFO: ngram_search_fwdtree.c(338): after: 41 root, 63 non-root channels, 16 single-phone wordsLast edited by mich04 (2013-12-19 20:34:23)
I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.
Offline
I figured out what I was doing wrong hw:1,0 not hw:0,1
I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.
Offline
Pages: 1