1
2
3
4
5
6
7
8
9
10 """
11 This documentation was automatically generated using original comments in
12 Doxygen format. As some C types and data structures cannot be directly mapped
13 into Python types, some non-trivial type conversion could have place.
14 Basically a type is replaced with another one that has the closest match, and
15 sometimes one argument of generated function comprises several arguments of the
16 original function (usually two).
17
18 Functions having error code as the return value and returning effective
19 value in one of its arguments are transformed so that the effective value is
20 returned in a regular fashion and run-time exception is being thrown in case of
21 negative error code.
22 """
23
24
25 from sys import version_info
26 if version_info >= (2, 6, 0):
28 from os.path import dirname
29 import imp
30 fp = None
31 try:
32 fp, pathname, description = imp.find_module('_pocketsphinx', [dirname(__file__)])
33 except ImportError:
34 import _pocketsphinx
35 return _pocketsphinx
36 if fp is not None:
37 try:
38 _mod = imp.load_module('_pocketsphinx', fp, pathname, description)
39 finally:
40 fp.close()
41 return _mod
42 _pocketsphinx = swig_import_helper()
43 del swig_import_helper
44 else:
45 import _pocketsphinx
46 del version_info
47 try:
48 _swig_property = property
49 except NameError:
50 pass
51
52
54 if (name == "thisown"):
55 return self.this.own(value)
56 if (name == "this"):
57 if type(value).__name__ == 'SwigPyObject':
58 self.__dict__[name] = value
59 return
60 method = class_type.__swig_setmethods__.get(name, None)
61 if method:
62 return method(self, value)
63 if (not static):
64 if _newclass:
65 object.__setattr__(self, name, value)
66 else:
67 self.__dict__[name] = value
68 else:
69 raise AttributeError("You cannot add attributes to %s" % self)
70
71
74
75
77 if (name == "thisown"):
78 return self.this.own()
79 method = class_type.__swig_getmethods__.get(name, None)
80 if method:
81 return method(self)
82 if (not static):
83 return object.__getattr__(self, name)
84 else:
85 raise AttributeError(name)
86
89
90
92 try:
93 strthis = "proxy of " + self.this.__repr__()
94 except:
95 strthis = ""
96 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
97
98 try:
99 _object = object
100 _newclass = 1
101 except AttributeError:
104 _newclass = 0
105
106
107 import sphinxbase
109 """Proxy of C Hypothesis struct"""
110 __swig_setmethods__ = {}
111 __setattr__ = lambda self, name, value: _swig_setattr(self, Hypothesis, name, value)
112 __swig_getmethods__ = {}
113 __getattr__ = lambda self, name: _swig_getattr(self, Hypothesis, name)
114 __repr__ = _swig_repr
115 __swig_setmethods__["hypstr"] = _pocketsphinx.Hypothesis_hypstr_set
116 __swig_getmethods__["hypstr"] = _pocketsphinx.Hypothesis_hypstr_get
117 if _newclass:
118 hypstr = _swig_property(_pocketsphinx.Hypothesis_hypstr_get, _pocketsphinx.Hypothesis_hypstr_set)
119 __swig_setmethods__["best_score"] = _pocketsphinx.Hypothesis_best_score_set
120 __swig_getmethods__["best_score"] = _pocketsphinx.Hypothesis_best_score_get
121 if _newclass:
122 best_score = _swig_property(_pocketsphinx.Hypothesis_best_score_get, _pocketsphinx.Hypothesis_best_score_set)
123 __swig_setmethods__["prob"] = _pocketsphinx.Hypothesis_prob_set
124 __swig_getmethods__["prob"] = _pocketsphinx.Hypothesis_prob_get
125 if _newclass:
126 prob = _swig_property(_pocketsphinx.Hypothesis_prob_get, _pocketsphinx.Hypothesis_prob_set)
127
128 - def __init__(self, hypstr, best_score, prob):
129 """__init__(Hypothesis self, char const * hypstr, int best_score, int prob) -> Hypothesis"""
130 this = _pocketsphinx.new_Hypothesis(hypstr, best_score, prob)
131 try:
132 self.this.append(this)
133 except:
134 self.this = this
135 __swig_destroy__ = _pocketsphinx.delete_Hypothesis
136 __del__ = lambda self: None
137 Hypothesis_swigregister = _pocketsphinx.Hypothesis_swigregister
138 Hypothesis_swigregister(Hypothesis)
139
141 """Proxy of C Segment struct"""
142 __swig_setmethods__ = {}
143 __setattr__ = lambda self, name, value: _swig_setattr(self, Segment, name, value)
144 __swig_getmethods__ = {}
145 __getattr__ = lambda self, name: _swig_getattr(self, Segment, name)
146 __repr__ = _swig_repr
147 __swig_setmethods__["word"] = _pocketsphinx.Segment_word_set
148 __swig_getmethods__["word"] = _pocketsphinx.Segment_word_get
149 if _newclass:
150 word = _swig_property(_pocketsphinx.Segment_word_get, _pocketsphinx.Segment_word_set)
151 __swig_setmethods__["ascore"] = _pocketsphinx.Segment_ascore_set
152 __swig_getmethods__["ascore"] = _pocketsphinx.Segment_ascore_get
153 if _newclass:
154 ascore = _swig_property(_pocketsphinx.Segment_ascore_get, _pocketsphinx.Segment_ascore_set)
155 __swig_setmethods__["lscore"] = _pocketsphinx.Segment_lscore_set
156 __swig_getmethods__["lscore"] = _pocketsphinx.Segment_lscore_get
157 if _newclass:
158 lscore = _swig_property(_pocketsphinx.Segment_lscore_get, _pocketsphinx.Segment_lscore_set)
159 __swig_setmethods__["lback"] = _pocketsphinx.Segment_lback_set
160 __swig_getmethods__["lback"] = _pocketsphinx.Segment_lback_get
161 if _newclass:
162 lback = _swig_property(_pocketsphinx.Segment_lback_get, _pocketsphinx.Segment_lback_set)
163 __swig_setmethods__["prob"] = _pocketsphinx.Segment_prob_set
164 __swig_getmethods__["prob"] = _pocketsphinx.Segment_prob_get
165 if _newclass:
166 prob = _swig_property(_pocketsphinx.Segment_prob_get, _pocketsphinx.Segment_prob_set)
167 __swig_setmethods__["start_frame"] = _pocketsphinx.Segment_start_frame_set
168 __swig_getmethods__["start_frame"] = _pocketsphinx.Segment_start_frame_get
169 if _newclass:
170 start_frame = _swig_property(_pocketsphinx.Segment_start_frame_get, _pocketsphinx.Segment_start_frame_set)
171 __swig_setmethods__["end_frame"] = _pocketsphinx.Segment_end_frame_set
172 __swig_getmethods__["end_frame"] = _pocketsphinx.Segment_end_frame_get
173 if _newclass:
174 end_frame = _swig_property(_pocketsphinx.Segment_end_frame_get, _pocketsphinx.Segment_end_frame_set)
175
177 """fromIter(void * itor) -> Segment"""
178 return _pocketsphinx.Segment_fromIter(itor)
179
180 if _newclass:
181 fromIter = staticmethod(fromIter)
182 __swig_getmethods__["fromIter"] = lambda x: fromIter
183 __swig_destroy__ = _pocketsphinx.delete_Segment
184 __del__ = lambda self: None
185
187 """__init__(Segment self) -> Segment"""
188 this = _pocketsphinx.new_Segment()
189 try:
190 self.this.append(this)
191 except:
192 self.this = this
193 Segment_swigregister = _pocketsphinx.Segment_swigregister
194 Segment_swigregister(Segment)
195
197 """Segment_fromIter(void * itor) -> Segment"""
198 return _pocketsphinx.Segment_fromIter(itor)
199
201 """Proxy of C NBest struct"""
202 __swig_setmethods__ = {}
203 __setattr__ = lambda self, name, value: _swig_setattr(self, NBest, name, value)
204 __swig_getmethods__ = {}
205 __getattr__ = lambda self, name: _swig_getattr(self, NBest, name)
206 __repr__ = _swig_repr
207 __swig_setmethods__["hypstr"] = _pocketsphinx.NBest_hypstr_set
208 __swig_getmethods__["hypstr"] = _pocketsphinx.NBest_hypstr_get
209 if _newclass:
210 hypstr = _swig_property(_pocketsphinx.NBest_hypstr_get, _pocketsphinx.NBest_hypstr_set)
211 __swig_setmethods__["score"] = _pocketsphinx.NBest_score_set
212 __swig_getmethods__["score"] = _pocketsphinx.NBest_score_get
213 if _newclass:
214 score = _swig_property(_pocketsphinx.NBest_score_get, _pocketsphinx.NBest_score_set)
215
217 """fromIter(void * itor) -> NBest"""
218 return _pocketsphinx.NBest_fromIter(itor)
219
220 if _newclass:
221 fromIter = staticmethod(fromIter)
222 __swig_getmethods__["fromIter"] = lambda x: fromIter
223
225 """hyp(NBest self) -> Hypothesis"""
226 return _pocketsphinx.NBest_hyp(self)
227
228 __swig_destroy__ = _pocketsphinx.delete_NBest
229 __del__ = lambda self: None
230
232 """__init__(NBest self) -> NBest"""
233 this = _pocketsphinx.new_NBest()
234 try:
235 self.this.append(this)
236 except:
237 self.this = this
238 NBest_swigregister = _pocketsphinx.NBest_swigregister
239 NBest_swigregister(NBest)
240
242 """NBest_fromIter(void * itor) -> NBest"""
243 return _pocketsphinx.NBest_fromIter(itor)
244
271
272 SegmentIterator_swigregister = _pocketsphinx.SegmentIterator_swigregister
273 SegmentIterator_swigregister(SegmentIterator)
274
301
302 NBestIterator_swigregister = _pocketsphinx.NBestIterator_swigregister
303 NBestIterator_swigregister(NBestIterator)
304
306 """Proxy of C Decoder struct"""
307 __swig_setmethods__ = {}
308 __setattr__ = lambda self, name, value: _swig_setattr(self, Decoder, name, value)
309 __swig_getmethods__ = {}
310 __getattr__ = lambda self, name: _swig_getattr(self, Decoder, name)
311 __repr__ = _swig_repr
312
314 """
315 __init__(Decoder self) -> Decoder
316 __init__(Decoder self, Config config) -> Decoder
317 """
318 this = _pocketsphinx.new_Decoder(*args)
319 try:
320 self.this.append(this)
321 except:
322 self.this = this
323 __swig_destroy__ = _pocketsphinx.delete_Decoder
324 __del__ = lambda self: None
325
327 """reinit(Decoder self, Config config)"""
328 return _pocketsphinx.Decoder_reinit(self, config)
329
330
331 - def load_dict(self, fdict, ffilter, format):
332 """load_dict(Decoder self, char const * fdict, char const * ffilter, char const * format)"""
333 return _pocketsphinx.Decoder_load_dict(self, fdict, ffilter, format)
334
335
337 """save_dict(Decoder self, char const * dictfile, char const * format)"""
338 return _pocketsphinx.Decoder_save_dict(self, dictfile, format)
339
340
341 - def add_word(self, word, phones, update):
342 """add_word(Decoder self, char const * word, char const * phones, int update)"""
343 return _pocketsphinx.Decoder_add_word(self, word, phones, update)
344
345
347 """lookup_word(Decoder self, char const * word) -> char *"""
348 return _pocketsphinx.Decoder_lookup_word(self, word)
349
350
352 """get_lattice(Decoder self) -> Lattice"""
353 return _pocketsphinx.Decoder_get_lattice(self)
354
355
357 """get_config(Decoder self) -> Config"""
358 return _pocketsphinx.Decoder_get_config(self)
359
360
364
365 if _newclass:
366 default_config = staticmethod(default_config)
367 __swig_getmethods__["default_config"] = lambda x: default_config
368
370 """file_config(char const * path) -> Config"""
371 return _pocketsphinx.Decoder_file_config(path)
372
373 if _newclass:
374 file_config = staticmethod(file_config)
375 __swig_getmethods__["file_config"] = lambda x: file_config
376
380
381
385
386
388 """end_utt(Decoder self)"""
389 return _pocketsphinx.Decoder_end_utt(self)
390
391
393 """process_raw(Decoder self, char const * SDATA, bool no_search, bool full_utt) -> int"""
394 return _pocketsphinx.Decoder_process_raw(self, SDATA, no_search, full_utt)
395
396
398 """process_cep(Decoder self, char const * SDATA, bool no_search, bool full_utt) -> int"""
399 return _pocketsphinx.Decoder_process_cep(self, SDATA, no_search, full_utt)
400
401
403 """hyp(Decoder self) -> Hypothesis"""
404 return _pocketsphinx.Decoder_hyp(self)
405
406
408 """get_fe(Decoder self) -> FrontEnd"""
409 return _pocketsphinx.Decoder_get_fe(self)
410
411
413 """get_feat(Decoder self) -> Feature"""
414 return _pocketsphinx.Decoder_get_feat(self)
415
416
420
421
423 """
424 get_fsg(Decoder self, char const * name) -> FsgModel
425
426 Get the finite-state grammar set object for this decoder.
427
428 If FSG decoding is not enabled, this returns NULL. Call
429 ps_set_fsgset() to enable it.
430
431 The current FSG set object for this decoder, or NULL if none is
432 available.
433 """
434 return _pocketsphinx.Decoder_get_fsg(self, name)
435
436
438 """
439 set_fsg(Decoder self, char const * name, FsgModel fsg)
440
441 Adds new search based on finite state grammar.
442
443 Associates FSG search with the provided name. The search can be
444 activated using ps_set_search().
445
446 See: ps_set_search
447 """
448 return _pocketsphinx.Decoder_set_fsg(self, name, fsg)
449
450
452 """
453 set_jsgf_file(Decoder self, char const * name, char const * path)
454
455 Adds new search using JSGF model.
456
457 Convenient method to load JSGF model and create a search.
458
459 See: ps_set_fsg
460 """
461 return _pocketsphinx.Decoder_set_jsgf_file(self, name, path)
462
463
465 """
466 set_jsgf_string(Decoder self, char const * name, char const * jsgf_string)
467
468 Adds new search using JSGF model.
469
470 Convenience method to parse JSGF model from string and create a
471 search.
472
473 See: ps_set_fsg
474 """
475 return _pocketsphinx.Decoder_set_jsgf_string(self, name, jsgf_string)
476
477
479 """
480 get_kws(Decoder self, char const * name) -> char const *
481
482 Get the current Key phrase to spot.
483
484 If KWS is not enabled, this returns NULL. Call ps_update_kws() to
485 enable it.
486
487 The current keyphrase to spot
488 """
489 return _pocketsphinx.Decoder_get_kws(self, name)
490
491
493 """
494 set_kws(Decoder self, char const * name, char const * keyfile)
495
496 Adds keyphrases from a file to spotting.
497
498 Associates KWS search with the provided name. The search can be
499 activated using ps_set_search().
500
501 See: ps_set_search
502 """
503 return _pocketsphinx.Decoder_set_kws(self, name, keyfile)
504
505
507 """
508 set_keyphrase(Decoder self, char const * name, char const * keyphrase)
509
510 Adds new keyphrase to spot.
511
512 Associates KWS search with the provided name. The search can be
513 activated using ps_set_search().
514
515 See: ps_set_search
516 """
517 return _pocketsphinx.Decoder_set_keyphrase(self, name, keyphrase)
518
519
521 """
522 set_allphone_file(Decoder self, char const * name, char const * lmfile)
523
524 Adds new search based on phone N-gram language model.
525
526 Convenient method to load N-gram model and create a search.
527
528 See: ps_set_allphone
529 """
530 return _pocketsphinx.Decoder_set_allphone_file(self, name, lmfile)
531
532
534 """
535 get_lm(Decoder self, char const * name) -> NGramModel
536
537 Get the language model set object for this decoder.
538
539 If N-Gram decoding is not enabled, this will return NULL. You will
540 need to enable it using ps_set_lmset().
541
542 The language model set object for this decoder. The decoder retains
543 ownership of this pointer, so you should not attempt to free it
544 manually. Use ngram_model_retain() if you wish to reuse it elsewhere.
545
546 """
547 return _pocketsphinx.Decoder_get_lm(self, name)
548
549
551 """
552 set_lm(Decoder self, char const * name, NGramModel lm)
553
554 Adds new search based on N-gram language model.
555
556 Associates N-gram search with the provided name. The search can be
557 activated using ps_set_search().
558
559 See: ps_set_search.
560 """
561 return _pocketsphinx.Decoder_set_lm(self, name, lm)
562
563
565 """
566 set_lm_file(Decoder self, char const * name, char const * path)
567
568 Adds new search based on N-gram language model.
569
570 Convenient method to load N-gram model and create a search.
571
572 See: ps_set_lm
573 """
574 return _pocketsphinx.Decoder_set_lm_file(self, name, path)
575
576
578 """get_logmath(Decoder self) -> LogMath"""
579 return _pocketsphinx.Decoder_get_logmath(self)
580
581
583 """
584 set_search(Decoder self, char const * search_name)
585
586 Actives search with the provided name.
587
588 Activates search with the provided name. The search must be added
589 before using either ps_set_fsg(), ps_set_lm() or ps_set_kws().
590
591 0 on success, -1 on failure
592 """
593 return _pocketsphinx.Decoder_set_search(self, search_name)
594
595
597 """
598 unset_search(Decoder self, char const * search_name)
599
600 Unsets the search and releases related resources.
601
602 Unsets the search previously added with using either ps_set_fsg(),
603 ps_set_lm() or ps_set_kws().
604
605 See: ps_set_fsg
606
607 ps_set_lm
608
609 ps_set_kws
610 """
611 return _pocketsphinx.Decoder_unset_search(self, search_name)
612
613
615 """
616 get_search(Decoder self) -> char const *
617
618 Returns name of curent search in decoder.
619
620 See: ps_set_search
621 """
622 return _pocketsphinx.Decoder_get_search(self)
623
624
626 """n_frames(Decoder self) -> int"""
627 return _pocketsphinx.Decoder_n_frames(self)
628
629
631 """seg(Decoder self) -> SegmentList"""
632 return _pocketsphinx.Decoder_seg(self)
633
634
636 """nbest(Decoder self) -> NBestList"""
637 return _pocketsphinx.Decoder_nbest(self)
638
639 Decoder_swigregister = _pocketsphinx.Decoder_swigregister
640 Decoder_swigregister(Decoder)
641
645
647 """Decoder_file_config(char const * path) -> Config"""
648 return _pocketsphinx.Decoder_file_config(path)
649
651 """Proxy of C Lattice struct"""
652 __swig_setmethods__ = {}
653 __setattr__ = lambda self, name, value: _swig_setattr(self, Lattice, name, value)
654 __swig_getmethods__ = {}
655 __getattr__ = lambda self, name: _swig_getattr(self, Lattice, name)
656 __repr__ = _swig_repr
657
659 """
660 __init__(Lattice self, char const * path) -> Lattice
661 __init__(Lattice self, Decoder decoder, char * path) -> Lattice
662 """
663 this = _pocketsphinx.new_Lattice(*args)
664 try:
665 self.this.append(this)
666 except:
667 self.this = this
668 __swig_destroy__ = _pocketsphinx.delete_Lattice
669 __del__ = lambda self: None
670
672 """
673 write(Lattice self, char const * path)
674
675 Write a lattice to disk.
676
677 0 for success, <0 on failure.
678 """
679 return _pocketsphinx.Lattice_write(self, path)
680
681
683 """
684 write_htk(Lattice self, char const * path)
685
686 Write a lattice to disk in HTK format.
687
688 0 for success, <0 on failure.
689 """
690 return _pocketsphinx.Lattice_write_htk(self, path)
691
692 Lattice_swigregister = _pocketsphinx.Lattice_swigregister
693 Lattice_swigregister(Lattice)
694
712 NBestList_swigregister = _pocketsphinx.NBestList_swigregister
713 NBestList_swigregister(NBestList)
714
732 SegmentList_swigregister = _pocketsphinx.SegmentList_swigregister
733 SegmentList_swigregister(SegmentList)
734
735
736