Package sphinxbase :: Module sphinxbase
[hide private]
[frames] | no frames]

Source Code for Module sphinxbase.sphinxbase

  1  # This file was automatically generated by SWIG (http://www.swig.org). 
  2  # Version 3.0.5 
  3  # 
  4  # Do not make changes to this file unless you know what you are doing--modify 
  5  # the SWIG interface file instead. 
  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): 
27 - def swig_import_helper():
28 from os.path import dirname 29 import imp 30 fp = None 31 try: 32 fp, pathname, description = imp.find_module('_sphinxbase', [dirname(__file__)]) 33 except ImportError: 34 import _sphinxbase 35 return _sphinxbase 36 if fp is not None: 37 try: 38 _mod = imp.load_module('_sphinxbase', fp, pathname, description) 39 finally: 40 fp.close() 41 return _mod
42 _sphinxbase = swig_import_helper() 43 del swig_import_helper 44 else: 45 import _sphinxbase 46 del version_info 47 try: 48 _swig_property = property 49 except NameError: 50 pass # Python < 2.2 doesn't have 'property'. 51 52
53 -def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
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
72 -def _swig_setattr(self, class_type, name, value):
73 return _swig_setattr_nondynamic(self, class_type, name, value, 0)
74 75
76 -def _swig_getattr_nondynamic(self, class_type, name, static=1):
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
87 -def _swig_getattr(self, class_type, name):
88 return _swig_getattr_nondynamic(self, class_type, name, 0)
89 90
91 -def _swig_repr(self):
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:
102 - class _object:
103 pass
104 _newclass = 0 105 106
107 -class Config(_object):
108 """Proxy of C Config struct""" 109 __swig_setmethods__ = {} 110 __setattr__ = lambda self, name, value: _swig_setattr(self, Config, name, value) 111 __swig_getmethods__ = {} 112 __getattr__ = lambda self, name: _swig_getattr(self, Config, name) 113
114 - def __init__(self, *args, **kwargs):
115 raise AttributeError("No constructor defined")
116 __repr__ = _swig_repr 117 __swig_destroy__ = _sphinxbase.delete_Config 118 __del__ = lambda self: None 119
120 - def set_boolean(self, key, val):
121 """set_boolean(Config self, char const * key, bool val)""" 122 return _sphinxbase.Config_set_boolean(self, key, val)
123 124
125 - def set_int(self, key, val):
126 """set_int(Config self, char const * key, int val)""" 127 return _sphinxbase.Config_set_int(self, key, val)
128 129
130 - def set_float(self, key, val):
131 """set_float(Config self, char const * key, double val)""" 132 return _sphinxbase.Config_set_float(self, key, val)
133 134
135 - def set_string(self, key, val):
136 """set_string(Config self, char const * key, char const * val)""" 137 return _sphinxbase.Config_set_string(self, key, val)
138 139
140 - def set_string_extra(self, key, val):
141 """set_string_extra(Config self, char const * key, char const * val)""" 142 return _sphinxbase.Config_set_string_extra(self, key, val)
143 144
145 - def exists(self, key):
146 """exists(Config self, char const * key) -> bool""" 147 return _sphinxbase.Config_exists(self, key)
148 149
150 - def get_boolean(self, key):
151 """get_boolean(Config self, char const * key) -> bool""" 152 return _sphinxbase.Config_get_boolean(self, key)
153 154
155 - def get_int(self, key):
156 """get_int(Config self, char const * key) -> int""" 157 return _sphinxbase.Config_get_int(self, key)
158 159
160 - def get_float(self, key):
161 """get_float(Config self, char const * key) -> double""" 162 return _sphinxbase.Config_get_float(self, key)
163 164
165 - def get_string(self, key):
166 """get_string(Config self, char const * key) -> char const *""" 167 return _sphinxbase.Config_get_string(self, key)
168 169 Config_swigregister = _sphinxbase.Config_swigregister 170 Config_swigregister(Config) 171
172 -class FrontEnd(_object):
173 """Proxy of C FrontEnd struct""" 174 __swig_setmethods__ = {} 175 __setattr__ = lambda self, name, value: _swig_setattr(self, FrontEnd, name, value) 176 __swig_getmethods__ = {} 177 __getattr__ = lambda self, name: _swig_getattr(self, FrontEnd, name) 178 __repr__ = _swig_repr 179
180 - def __init__(self):
181 """__init__(FrontEnd self) -> FrontEnd""" 182 this = _sphinxbase.new_FrontEnd() 183 try: 184 self.this.append(this) 185 except: 186 self.this = this
187 __swig_destroy__ = _sphinxbase.delete_FrontEnd 188 __del__ = lambda self: None 189
190 - def output_size(self):
191 """output_size(FrontEnd self) -> int""" 192 return _sphinxbase.FrontEnd_output_size(self)
193 194
195 - def process_utt(self, spch, nsamps, cep_block):
196 """ 197 process_utt(FrontEnd self, char * spch, size_t nsamps, mfcc_t *** cep_block) -> int 198 199 Process a block of samples, returning as many frames as possible. 200 201 This function processes all the samples in a block of data and returns 202 a newly allocated block of feature vectors. This block needs to be 203 freed with fe_free_2d() after use. 204 205 It is possible for there to be some left-over data which could not fit 206 in a complete frame. This data can be processed with fe_end_utt(). 207 208 This function is deprecated in favor of fe_process_frames(). 209 210 0 for success, <0 for failure (see enum fe_error_e) 211 """ 212 return _sphinxbase.FrontEnd_process_utt(self, spch, nsamps, cep_block)
213 214 FrontEnd_swigregister = _sphinxbase.FrontEnd_swigregister 215 FrontEnd_swigregister(FrontEnd) 216
217 -class Feature(_object):
218 """Proxy of C Feature struct""" 219 __swig_setmethods__ = {} 220 __setattr__ = lambda self, name, value: _swig_setattr(self, Feature, name, value) 221 __swig_getmethods__ = {} 222 __getattr__ = lambda self, name: _swig_getattr(self, Feature, name) 223 __repr__ = _swig_repr 224 __swig_destroy__ = _sphinxbase.delete_Feature 225 __del__ = lambda self: None 226
227 - def __init__(self):
228 """__init__(Feature self) -> Feature""" 229 this = _sphinxbase.new_Feature() 230 try: 231 self.this.append(this) 232 except: 233 self.this = this
234 Feature_swigregister = _sphinxbase.Feature_swigregister 235 Feature_swigregister(Feature) 236
237 -class FsgModel(_object):
238 """Proxy of C FsgModel struct""" 239 __swig_setmethods__ = {} 240 __setattr__ = lambda self, name, value: _swig_setattr(self, FsgModel, name, value) 241 __swig_getmethods__ = {} 242 __getattr__ = lambda self, name: _swig_getattr(self, FsgModel, name) 243 __repr__ = _swig_repr 244
245 - def __init__(self, *args):
246 """ 247 __init__(FsgModel self, char const * name, LogMath logmath, float lw, int n) -> FsgModel 248 __init__(FsgModel self, char const * path, LogMath logmath, float lw) -> FsgModel 249 """ 250 this = _sphinxbase.new_FsgModel(*args) 251 try: 252 self.this.append(this) 253 except: 254 self.this = this
255 __swig_destroy__ = _sphinxbase.delete_FsgModel 256 __del__ = lambda self: None 257
258 - def word_id(self, word):
259 """ 260 word_id(FsgModel self, char const * word) -> int 261 262 Look up a word in the FSG vocabulary. 263 264 Word ID for this word 265 """ 266 return _sphinxbase.FsgModel_word_id(self, word)
267 268
269 - def word_add(self, word):
270 """ 271 word_add(FsgModel self, char const * word) -> int 272 273 Add a word to the FSG vocabulary. 274 275 Word ID for this new word. 276 """ 277 return _sphinxbase.FsgModel_word_add(self, word)
278 279
280 - def trans_add(self, src, dst, logp, wid):
281 """ 282 trans_add(FsgModel self, int src, int dst, int logp, int wid) 283 284 Add the given transition to the FSG transition matrix. 285 286 Duplicates (i.e., two transitions between the same states, with the 287 same word label) are flagged and only the highest prob retained. 288 """ 289 return _sphinxbase.FsgModel_trans_add(self, src, dst, logp, wid)
290 291
292 - def null_trans_add(self, src, dst, logp):
293 """ 294 null_trans_add(FsgModel self, int src, int dst, int logp) -> int 295 296 Add a null transition between the given states. 297 298 There can be at most one null transition between the given states; 299 duplicates are flagged and only the best prob retained. Transition 300 probs must be <= 1 (i.e., logprob <= 0). 301 302 1 if a new transition was added, 0 if the prob of an existing 303 transition was upgraded; -1 if nothing was changed. 304 """ 305 return _sphinxbase.FsgModel_null_trans_add(self, src, dst, logp)
306 307
308 - def tag_trans_add(self, src, dst, logp, wid):
309 """ 310 tag_trans_add(FsgModel self, int src, int dst, int logp, int wid) -> int 311 312 Add a "tag" transition between the given states. 313 314 A "tag" transition is a null transition with a non-null word ID, 315 which corresponds to a semantic tag or other symbol to be output when 316 this transition is taken. 317 318 As above, there can be at most one null or tag transition between the 319 given states; duplicates are flagged and only the best prob retained. 320 Transition probs must be <= 1 (i.e., logprob <= 0). 321 322 1 if a new transition was added, 0 if the prob of an existing 323 transition was upgraded; -1 if nothing was changed. 324 """ 325 return _sphinxbase.FsgModel_tag_trans_add(self, src, dst, logp, wid)
326 327
328 - def add_silence(self, silword, state, silprob):
329 """ 330 add_silence(FsgModel self, char const * silword, int state, float silprob) -> int 331 332 Add silence word transitions to each state in given FSG. 333 334 Parameters: 335 ----------- 336 337 state: state to add a self-loop to, or -1 for all states. 338 339 silprob: probability of silence transition. 340 """ 341 return _sphinxbase.FsgModel_add_silence(self, silword, state, silprob)
342 343
344 - def add_alt(self, baseword, altword):
345 """ 346 add_alt(FsgModel self, char const * baseword, char const * altword) -> int 347 348 Add alternate pronunciation transitions for a word in given FSG. 349 """ 350 return _sphinxbase.FsgModel_add_alt(self, baseword, altword)
351 352
353 - def writefile(self, path):
354 """ 355 writefile(FsgModel self, char const * path) 356 357 Write FSG to a file. 358 """ 359 return _sphinxbase.FsgModel_writefile(self, path)
360 361 FsgModel_swigregister = _sphinxbase.FsgModel_swigregister 362 FsgModel_swigregister(FsgModel) 363
364 -class JsgfRule(_object):
365 """Proxy of C JsgfRule struct""" 366 __swig_setmethods__ = {} 367 __setattr__ = lambda self, name, value: _swig_setattr(self, JsgfRule, name, value) 368 __swig_getmethods__ = {} 369 __getattr__ = lambda self, name: _swig_getattr(self, JsgfRule, name) 370 __repr__ = _swig_repr 371
372 - def __init__(self):
373 """__init__(JsgfRule self) -> JsgfRule""" 374 this = _sphinxbase.new_JsgfRule() 375 try: 376 self.this.append(this) 377 except: 378 self.this = this
379
380 - def fromIter(itor):
381 """fromIter(void * itor) -> JsgfRule""" 382 return _sphinxbase.JsgfRule_fromIter(itor)
383 384 if _newclass: 385 fromIter = staticmethod(fromIter) 386 __swig_getmethods__["fromIter"] = lambda x: fromIter 387
388 - def get_name(self):
389 """get_name(JsgfRule self) -> char const *""" 390 return _sphinxbase.JsgfRule_get_name(self)
391 392
393 - def is_public(self):
394 """is_public(JsgfRule self) -> bool""" 395 return _sphinxbase.JsgfRule_is_public(self)
396 397 __swig_destroy__ = _sphinxbase.delete_JsgfRule 398 __del__ = lambda self: None
399 JsgfRule_swigregister = _sphinxbase.JsgfRule_swigregister 400 JsgfRule_swigregister(JsgfRule) 401
402 -def JsgfRule_fromIter(itor):
403 """JsgfRule_fromIter(void * itor) -> JsgfRule""" 404 return _sphinxbase.JsgfRule_fromIter(itor)
405
406 -class NGramModel(_object):
407 """Proxy of C NGramModel struct""" 408 __swig_setmethods__ = {} 409 __setattr__ = lambda self, name, value: _swig_setattr(self, NGramModel, name, value) 410 __swig_getmethods__ = {} 411 __getattr__ = lambda self, name: _swig_getattr(self, NGramModel, name) 412 __repr__ = _swig_repr 413
414 - def fromIter(itor):
415 """fromIter(void * itor) -> NGramModel""" 416 return _sphinxbase.NGramModel_fromIter(itor)
417 418 if _newclass: 419 fromIter = staticmethod(fromIter) 420 __swig_getmethods__["fromIter"] = lambda x: fromIter 421
422 - def __init__(self, *args):
423 """ 424 __init__(NGramModel self, char const * path) -> NGramModel 425 __init__(NGramModel self, Config config, LogMath logmath, char const * path) -> NGramModel 426 """ 427 this = _sphinxbase.new_NGramModel(*args) 428 try: 429 self.this.append(this) 430 except: 431 self.this = this
432 __swig_destroy__ = _sphinxbase.delete_NGramModel 433 __del__ = lambda self: None 434
435 - def write(self, path, ftype):
436 """ 437 write(NGramModel self, char const * path, int ftype) 438 439 Write an N-Gram model to disk. 440 441 0 for success, <0 on error 442 """ 443 return _sphinxbase.NGramModel_write(self, path, ftype)
444 445
446 - def str_to_type(self, str):
447 """str_to_type(NGramModel self, char const * str) -> int""" 448 return _sphinxbase.NGramModel_str_to_type(self, str)
449 450
451 - def type_to_str(self, type):
452 """type_to_str(NGramModel self, int type) -> char const *""" 453 return _sphinxbase.NGramModel_type_to_str(self, type)
454 455
456 - def casefold(self, kase):
457 """ 458 casefold(NGramModel self, int kase) 459 460 Case-fold word strings in an N-Gram model. 461 462 WARNING: This is not Unicode aware, so any non-ASCII characters will 463 not be converted. 464 """ 465 return _sphinxbase.NGramModel_casefold(self, kase)
466 467
468 - def size(self):
469 """size(NGramModel self) -> int""" 470 return _sphinxbase.NGramModel_size(self)
471 472
473 - def add_word(self, word, weight):
474 """ 475 add_word(NGramModel self, char const * word, float weight) -> int 476 477 Add a word (unigram) to the language model. 478 479 The semantics of this are not particularly well-defined for model 480 sets, and may be subject to change. Currently this will add the word 481 to all of the submodels 482 483 Parameters: 484 ----------- 485 486 model: The model to add a word to. 487 488 word: Text of the word to add. 489 490 weight: Weight of this word relative to the uniform distribution. 491 492 The word ID for the new word. 493 """ 494 return _sphinxbase.NGramModel_add_word(self, word, weight)
495 496
497 - def prob(self, n):
498 """prob(NGramModel self, size_t n) -> int""" 499 return _sphinxbase.NGramModel_prob(self, n)
500 501 NGramModel_swigregister = _sphinxbase.NGramModel_swigregister 502 NGramModel_swigregister(NGramModel) 503
504 -def NGramModel_fromIter(itor):
505 """NGramModel_fromIter(void * itor) -> NGramModel""" 506 return _sphinxbase.NGramModel_fromIter(itor)
507
508 -class LogMath(_object):
509 """Proxy of C LogMath struct""" 510 __swig_setmethods__ = {} 511 __setattr__ = lambda self, name, value: _swig_setattr(self, LogMath, name, value) 512 __swig_getmethods__ = {} 513 __getattr__ = lambda self, name: _swig_getattr(self, LogMath, name) 514 __repr__ = _swig_repr 515
516 - def __init__(self):
517 """__init__(LogMath self) -> LogMath""" 518 this = _sphinxbase.new_LogMath() 519 try: 520 self.this.append(this) 521 except: 522 self.this = this
523 __swig_destroy__ = _sphinxbase.delete_LogMath 524 __del__ = lambda self: None 525
526 - def exp(self, prob):
527 """exp(LogMath self, int prob) -> double""" 528 return _sphinxbase.LogMath_exp(self, prob)
529 530 LogMath_swigregister = _sphinxbase.LogMath_swigregister 531 LogMath_swigregister(LogMath) 532
533 -class NGramModelSetIterator(_object):
534 """Proxy of C NGramModelSetIterator struct""" 535 __swig_setmethods__ = {} 536 __setattr__ = lambda self, name, value: _swig_setattr(self, NGramModelSetIterator, name, value) 537 __swig_getmethods__ = {} 538 __getattr__ = lambda self, name: _swig_getattr(self, NGramModelSetIterator, name) 539 __repr__ = _swig_repr 540
541 - def __init__(self, ptr):
542 """__init__(NGramModelSetIterator self, void * ptr) -> NGramModelSetIterator""" 543 this = _sphinxbase.new_NGramModelSetIterator(ptr) 544 try: 545 self.this.append(this) 546 except: 547 self.this = this
548 __swig_destroy__ = _sphinxbase.delete_NGramModelSetIterator 549 __del__ = lambda self: None 550
551 - def next(self):
552 """next(NGramModelSetIterator self) -> NGramModel""" 553 return _sphinxbase.NGramModelSetIterator_next(self)
554 555
556 - def __next__(self):
557 """__next__(NGramModelSetIterator self) -> NGramModel""" 558 return _sphinxbase.NGramModelSetIterator___next__(self)
559 560 NGramModelSetIterator_swigregister = _sphinxbase.NGramModelSetIterator_swigregister 561 NGramModelSetIterator_swigregister(NGramModelSetIterator) 562
563 -class JsgfIterator(_object):
564 """Proxy of C JsgfIterator struct""" 565 __swig_setmethods__ = {} 566 __setattr__ = lambda self, name, value: _swig_setattr(self, JsgfIterator, name, value) 567 __swig_getmethods__ = {} 568 __getattr__ = lambda self, name: _swig_getattr(self, JsgfIterator, name) 569 __repr__ = _swig_repr 570
571 - def __init__(self, ptr):
572 """__init__(JsgfIterator self, void * ptr) -> JsgfIterator""" 573 this = _sphinxbase.new_JsgfIterator(ptr) 574 try: 575 self.this.append(this) 576 except: 577 self.this = this
578 __swig_destroy__ = _sphinxbase.delete_JsgfIterator 579 __del__ = lambda self: None 580
581 - def next(self):
582 """next(JsgfIterator self) -> JsgfRule""" 583 return _sphinxbase.JsgfIterator_next(self)
584 585
586 - def __next__(self):
587 """__next__(JsgfIterator self) -> JsgfRule""" 588 return _sphinxbase.JsgfIterator___next__(self)
589 590 JsgfIterator_swigregister = _sphinxbase.JsgfIterator_swigregister 591 JsgfIterator_swigregister(JsgfIterator) 592
593 -class NGramModelSet(_object):
594 """Proxy of C NGramModelSet struct""" 595 __swig_setmethods__ = {} 596 __setattr__ = lambda self, name, value: _swig_setattr(self, NGramModelSet, name, value) 597 __swig_getmethods__ = {} 598 __getattr__ = lambda self, name: _swig_getattr(self, NGramModelSet, name) 599 __repr__ = _swig_repr 600
601 - def __iter__(self):
602 """__iter__(NGramModelSet self) -> NGramModelSetIterator""" 603 return _sphinxbase.NGramModelSet___iter__(self)
604 605
606 - def __init__(self, config, logmath, path):
607 """__init__(NGramModelSet self, Config config, LogMath logmath, char const * path) -> NGramModelSet""" 608 this = _sphinxbase.new_NGramModelSet(config, logmath, path) 609 try: 610 self.this.append(this) 611 except: 612 self.this = this
613 __swig_destroy__ = _sphinxbase.delete_NGramModelSet 614 __del__ = lambda self: None 615
616 - def count(self):
617 """count(NGramModelSet self) -> int""" 618 return _sphinxbase.NGramModelSet_count(self)
619 620
621 - def add(self, model, name, weight, reuse_widmap):
622 """add(NGramModelSet self, NGramModel model, char const * name, float weight, bool reuse_widmap) -> NGramModel""" 623 return _sphinxbase.NGramModelSet_add(self, model, name, weight, reuse_widmap)
624 625
626 - def select(self, name):
627 """select(NGramModelSet self, char const * name) -> NGramModel""" 628 return _sphinxbase.NGramModelSet_select(self, name)
629 630
631 - def lookup(self, name):
632 """lookup(NGramModelSet self, char const * name) -> NGramModel""" 633 return _sphinxbase.NGramModelSet_lookup(self, name)
634 635
636 - def current(self):
637 """current(NGramModelSet self) -> char const *""" 638 return _sphinxbase.NGramModelSet_current(self)
639 640 NGramModelSet_swigregister = _sphinxbase.NGramModelSet_swigregister 641 NGramModelSet_swigregister(NGramModelSet) 642
643 -class Jsgf(_object):
644 """Proxy of C Jsgf struct""" 645 __swig_setmethods__ = {} 646 __setattr__ = lambda self, name, value: _swig_setattr(self, Jsgf, name, value) 647 __swig_getmethods__ = {} 648 __getattr__ = lambda self, name: _swig_getattr(self, Jsgf, name) 649 __repr__ = _swig_repr 650
651 - def __iter__(self):
652 """__iter__(Jsgf self) -> JsgfIterator""" 653 return _sphinxbase.Jsgf___iter__(self)
654 655
656 - def __init__(self, path):
657 """__init__(Jsgf self, char const * path) -> Jsgf""" 658 this = _sphinxbase.new_Jsgf(path) 659 try: 660 self.this.append(this) 661 except: 662 self.this = this
663 __swig_destroy__ = _sphinxbase.delete_Jsgf 664 __del__ = lambda self: None 665
666 - def get_name(self):
667 """get_name(Jsgf self) -> char const *""" 668 return _sphinxbase.Jsgf_get_name(self)
669 670
671 - def get_rule(self, name):
672 """ 673 get_rule(Jsgf self, char const * name) -> JsgfRule 674 675 Get a rule by name from a grammar. 676 677 Name should not contain brackets. 678 """ 679 return _sphinxbase.Jsgf_get_rule(self, name)
680 681
682 - def build_fsg(self, rule, logmath, lw):
683 """ 684 build_fsg(Jsgf self, JsgfRule rule, LogMath logmath, float lw) -> FsgModel 685 686 Build a Sphinx FSG object from a JSGF rule. 687 """ 688 return _sphinxbase.Jsgf_build_fsg(self, rule, logmath, lw)
689 690 Jsgf_swigregister = _sphinxbase.Jsgf_swigregister 691 Jsgf_swigregister(Jsgf) 692 693 # This file is compatible with both classic and new-style classes. 694