speech_recognition
|
Public Member Functions | |
def | __init__ (self, model_path, grammar_file_string, target) |
def | autocomplete (self) |
def | check_word (self, recognition='', initial_list=[]) |
def | expand_tree_ (self) |
def | get_words_ (self) |
def | parse (self, sentence) |
def | print_graphviz (self) |
def | print_nicely (self, sentence_list) |
Public Attributes | |
grammar_file | |
grammar_string | |
model_path | |
model_path_tmp | |
parser | |
target | |
tree | |
Class Grammar uses as input a grammar file with extension '.fcfg' and has two functions: get_rule_element: extracts the defined grammar rules get_words: extracts the unique words and creates 'corpus.txt' which is used to build 'G.fst'
Definition at line 14 of file kaldi_grammar.py.
def speech_recognition.kaldi_grammar.Grammar.__init__ | ( | self, | |
model_path, | |||
grammar_file_string, | |||
target | |||
) |
Definition at line 20 of file kaldi_grammar.py.
def speech_recognition.kaldi_grammar.Grammar.autocomplete | ( | self | ) |
# TODO: expand the full tree, not only the first words # replace raw_input with the speech recognition output # add an option to skip a word if it is not a match and to check the # next word
Definition at line 82 of file kaldi_grammar.py.
def speech_recognition.kaldi_grammar.Grammar.check_word | ( | self, | |
recognition = '' , |
|||
initial_list = [] |
|||
) |
Checks if the recognised word is matching with the first element in the expanded sentences As output it keeps a list of only the sentences, starting with the recognised word. :param recognition: the recognised word :param initial_list: bla :return filtered_list: sentence list, filtered by its first word
Definition at line 128 of file kaldi_grammar.py.
def speech_recognition.kaldi_grammar.Grammar.expand_tree_ | ( | self | ) |
Expands the grammar tree based on the words in the grammar rules for the pre-set target :return: tree of sentence nodes
Definition at line 177 of file kaldi_grammar.py.
def speech_recognition.kaldi_grammar.Grammar.get_words_ | ( | self | ) |
Extracts list with all the unique words, used within the grammar and create file 'corpus.txt' which is used to build 'G.fst'
Definition at line 50 of file kaldi_grammar.py.
def speech_recognition.kaldi_grammar.Grammar.parse | ( | self, | |
sentence | |||
) |
Parses the input sentence to generate the semantics for the pre-set target :param sentence: The sentence to be parsed :return: semantics
Definition at line 188 of file kaldi_grammar.py.
def speech_recognition.kaldi_grammar.Grammar.print_graphviz | ( | self | ) |
Wrapper around the print_graphviz function to print the current tree
Definition at line 199 of file kaldi_grammar.py.
def speech_recognition.kaldi_grammar.Grammar.print_nicely | ( | self, | |
sentence_list | |||
) |
Prints cleanly the output of the tree traversal functions :param sentence_list: list of possible completions
Definition at line 166 of file kaldi_grammar.py.
speech_recognition.kaldi_grammar.Grammar.grammar_file |
Definition at line 37 of file kaldi_grammar.py.
speech_recognition.kaldi_grammar.Grammar.grammar_string |
Definition at line 38 of file kaldi_grammar.py.
speech_recognition.kaldi_grammar.Grammar.model_path |
Definition at line 22 of file kaldi_grammar.py.
speech_recognition.kaldi_grammar.Grammar.model_path_tmp |
Definition at line 23 of file kaldi_grammar.py.
speech_recognition.kaldi_grammar.Grammar.parser |
Definition at line 36 of file kaldi_grammar.py.
speech_recognition.kaldi_grammar.Grammar.target |
Definition at line 44 of file kaldi_grammar.py.
speech_recognition.kaldi_grammar.Grammar.tree |
Definition at line 48 of file kaldi_grammar.py.