AJ Python Speech Recog Part Five
AJ Python Speech Recog Part Five
class pocketsphinx.Vad(mode=PS_VAD_LOOSE,
sample_rate=PS_VAD_DEFAULT_SAMPLE_RATE,
frame_length=PS_VAD_DEFAULT_FRAME_LENGTH)
frame_bytes
Type: int
frame_length
Length of a frame in seconds (may be different from the one requested in the
constructor!)
Type: float
sample_rate
Type: int
Other classes
The “parser” is very much not strict, so you can also pass a sort of pseudo-YAML
to it, e.g.:
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 22 of 32
Main pocketsphinx package — PocketSphinx 5.0.1 documentation 06/08/23, 12:19 AM
You can also ini!alize an empty Config and set arguments in it directly:
config = Config()
config["hmm"] = "path/to/things"
In general, a Config mostly acts like a dic!onary, and can be iterated over in the
same fashion. However, a#emp!ng to access a parameter that does not already
exist will raise a KeyError .
Many parameters have default values. Also, when construc!ng a Config directly
(as opposed to parsing JSON), hmm , lm , and dict are set to the default models
(some kind of US English models of unknown origin + CMUDict). You can prevent
this by passing None for any of these parameters, e.g.:
Decoder ini!aliza!on will fail if more than one of lm , jsgf , fsg , keyphrase ,
kws , allphone , or lmctl are set in the configura!on. To make life easier, and
because there is no possible case in which you would do this inten!onally, if you
ini!alize a Decoder or Config with any of these (and not lm ), the default lm
value will be removed. This is not the case if you decide to set one of them in an
exis!ng Config , so in that case you must make sure to set lm to None :
config["jsgf"] = "spam_eggs_and_spam.gram"
config["lm"] = None
You may also call default_search_args() a$er the fact to set hmm , lm , and
dict to the system defaults. Note that this will set them uncondi!onally.
default_search_args(self)
Set hmm , lm , and dict to the default ones (some kind of US English models
of unknown origin + CMUDict). This will overwrite any previous values for
these parameters, and does not check if the files exist.
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 23 of 32
Main pocketsphinx package — PocketSphinx 5.0.1 documentation 06/08/23, 12:19 AM
describe(self)
dumps(self)
This produces JSON from a configura!on object, with default values included.
exists(self, key)
get_boolean(self, key)
get_float(self, key)
get_int(self, key)
get_string(self, key)
items(self)
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 24 of 32
Main pocketsphinx package — PocketSphinx 5.0.1 documentation 06/08/23, 12:19 AM
sta!c parse_json(json)
default
doc
Descrip!on of parameter.
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 25 of 32
Main pocketsphinx package — PocketSphinx 5.0.1 documentation 06/08/23, 12:19 AM
name
required
type
add(self, p, q)
exp(self, p)
get_zero(self)
ln_to_log(self, p)
log(self, p)
log10_to_log(self, p)
log_to_ln(self, p)
log_to_log10(self, p)
JSGF parser.
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 26 of 32
Main pocketsphinx package — PocketSphinx 5.0.1 documentation 06/08/23, 12:19 AM
get_name(self)
get_rule(self, name)
class pocketsphinx.JsgfRule
JSGF Rule.
get_name(self)
is_public(self)
prob(self, words)
size(self)
accept(self, words)
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 27 of 32
Main pocketsphinx package — PocketSphinx 5.0.1 documentation 06/08/23, 12:19 AM
set_final_state(self, state)
set_start_state(self, state)
word_add(self, word)
word_id(self, word)
word_str(self, wid)
class pocketsphinx.Lattice
Word la%ce.
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 28 of 32
Main pocketsphinx package — PocketSphinx 5.0.1 documentation 06/08/23, 12:19 AM
class pocketsphinx.Segment
word
Name of word.
Type: str
start_frame
Type: int
end_frame
Type: int
ascore
Type: float
lscore
Type: float
lback
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 29 of 32
Main pocketsphinx package — PocketSphinx 5.0.1 documentation 06/08/23, 12:19 AM
Type: int
hypstr
Recognized text.
Type: str
score
Recogni!on score.
Type: float
best_score
Type: float
prob
Posterior probability.
Type: float
class pocketsphinx.Alignment
For the moment this is read-only. You are able to iterate over the words, phones,
or states in it, as well as sub-itera!ng over each of their children, as described in
AlignmentEntry .
phones(self)
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 30 of 32
Main pocketsphinx package — PocketSphinx 5.0.1 documentation 06/08/23, 12:19 AM
states(self)
words(self)
class pocketsphinx.AlignmentEntry
Itera!ng over this will iterate over its children (i.e. the phones in a word or the
states in a phone) if any. For example:
name
Type: str
start
Type: int
duration
Dura!on in frames.
Type: int
score
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 31 of 32
Main pocketsphinx package — PocketSphinx 5.0.1 documentation 06/08/23, 12:19 AM
Type: float
https://pocketsphinx.readthedocs.io/en/latest/pocketsphinx.html Page 32 of 32