(What a computer might look like)
(What a cheaper, easier computer might look like)
espeak 'I'\''m afraid I can'\''t do that dave'
pico2wave -w /tmp/zzz.wav 'I'\''m afraid I can'\''t do that dave'; aplay /tmp/zzz.wav
pico2wave -l en-GB -w /tmp/zzz.wav 'I'\''m afraid I can'\''t do that dave'; aplay /tmp/zzz.wav
language_model="yourlanguagemodel" keyphrase="computer" stdbuf -o 0 pocketsphinx_continuous -inmic yes -lm "$language_model".lm \ -dict "$language_model".dic -keyphrase "$keyphrase" \ -kws_threshold 1e-20 2>/dev/null |\ stdbuf -o 0 egrep -v 'READY...|Listening...|Stopped listening' |\ stdbuf -o 0 sed -e 's/^[0-9][0-9]*[:] //' |\ stdbuf -o 0 grep COMPUTER |\ stdbuf -o 0 sed -e 's/^.*COMPUTER //' |\ stdbuf -o 0 tee recog.txt | \ stdbuf -o 0 cat > /tmp/snis-natural-language-fifo
language_model="yourlanguagemodel" keyphrase="computer"stdbuf -o 0 pocketsphinx_continuous -inmic yes -lm "$language_model".lm \ -dict "$language_model".dic -keyphrase "$keyphrase" \ -kws_threshold 1e-20 2>/dev/null |\stdbuf -o 0 egrep -v 'READY...|Listening...|Stopped listening' |\stdbuf -o 0 sed -e 's/^[0-9][0-9]*[:] //' |\stdbuf -o 0 grep COMPUTER |\stdbuf -o 0 sed -e 's/^.*COMPUTER //' |\stdbuf -o 0 tee recog.txt | \stdbuf -o 0 cat > /tmp/snis-natural-language-fifo
language_model="yourlanguagemodel" keyphrase="computer" stdbuf -o 0pocketsphinx_continuous -inmic yes -lm "$language_model".lm \ -dict "$language_model".dic -keyphrase "$keyphrase" \ -kws_threshold 1e-20 2>/dev/null |\ stdbuf -o 0 egrep -v 'READY...|Listening...|Stopped listening' |\ stdbuf -o 0 sed -e 's/^[0-9][0-9]*[:] //' |\ stdbuf -o 0 grep COMPUTER |\ stdbuf -o 0 sed -e 's/^.*COMPUTER //' |\ stdbuf -o 0 tee recog.txt | \ stdbuf -o 0 cat > /tmp/snis-natural-language-fifo
language_model="yourlanguagemodel" keyphrase="computer" stdbuf -o 0 pocketsphinx_continuous -inmic yes -lm "$language_model".lm \ -dict "$language_model".dic -keyphrase "$keyphrase" \ -kws_threshold 1e-20 2>/dev/null |\ stdbuf -o 0egrep -v 'READY...|Listening...|Stopped listening' |\ stdbuf -o 0sed -e 's/^[0-9][0-9]*[:] //' |\ stdbuf -o 0 grep COMPUTER |\ stdbuf -o 0 sed -e 's/^.*COMPUTER //' |\ stdbuf -o 0 tee recog.txt | \ stdbuf -o 0 cat > /tmp/snis-natural-language-fifo
language_model="yourlanguagemodel" keyphrase="computer" stdbuf -o 0 pocketsphinx_continuous -inmic yes -lm "$language_model".lm \ -dict "$language_model".dic -keyphrase "$keyphrase" \ -kws_threshold 1e-20 2>/dev/null |\ stdbuf -o 0 egrep -v 'READY...|Listening...|Stopped listening' |\ stdbuf -o 0 sed -e 's/^[0-9][0-9]*[:] //' |\ stdbuf -o 0grep COMPUTER |\ stdbuf -o 0sed -e 's/^.*COMPUTER //' |\ stdbuf -o 0 tee recog.txt | \ stdbuf -o 0 cat > /tmp/snis-natural-language-fifo
language_model="yourlanguagemodel" keyphrase="computer" stdbuf -o 0 pocketsphinx_continuous -inmic yes -lm "$language_model".lm \ -dict "$language_model".dic -keyphrase "$keyphrase" \ -kws_threshold 1e-20 2>/dev/null |\ stdbuf -o 0 egrep -v 'READY...|Listening...|Stopped listening' |\ stdbuf -o 0 sed -e 's/^[0-9][0-9]*[:] //' |\ stdbuf -o 0 grep COMPUTER |\ stdbuf -o 0 sed -e 's/^.*COMPUTER //' |\ stdbuf -o 0tee recog.txt | \ stdbuf -o 0 cat > /tmp/snis-natural-language-fifo
language_model="yourlanguagemodel" keyphrase="computer" stdbuf -o 0 pocketsphinx_continuous -inmic yes -lm "$language_model".lm \ -dict "$language_model".dic -keyphrase "$keyphrase" \ -kws_threshold 1e-20 2>/dev/null |\ stdbuf -o 0 egrep -v 'READY...|Listening...|Stopped listening' |\ stdbuf -o 0 sed -e 's/^[0-9][0-9]*[:] //' |\ stdbuf -o 0 grep COMPUTER |\ stdbuf -o 0 sed -e 's/^.*COMPUTER //' |\ stdbuf -o 0 tee recog.txt | \ stdbuf -o 0cat > /tmp/snis-natural-language-fifo
snis_nl_add_dictionary_word("coolant", "coolant", POS_NOUN); snis_nl_add_dictionary_word("power", "power", POS_NOUN); snis_nl_add_dictionary_word("off", "off", POS_PREPOSITION); snis_nl_add_dictionary_word("on", "on", POS_PREPOSITION); snis_nl_add_dictionary_word("up", "up", POS_ADJECTIVE); snis_nl_add_dictionary_word("down", "down", POS_ADJECTIVE); snis_nl_add_dictionary_word("port", "port", POS_ADJECTIVE); snis_nl_add_dictionary_word("left", "port", POS_ADJECTIVE);
snis_nl_add_dictionary_verb("set", "set", "npq", nl_set_npq); /* set warp drive power to 50 percent */ snis_nl_add_dictionary_verb("set", "set", "npn", nl_set_npn); /* set a course for the planet */ snis_nl_add_dictionary_verb("set", "set", "npan", nl_set_npn); /* set a course for the nearest planet */ snis_nl_add_dictionary_verb("set", "set", "npnq", nl_set_npnq); /* set a course for starbase one */ snis_nl_add_dictionary_verb("plot", "plot", "npn", nl_set_npn); snis_nl_add_dictionary_verb("plot", "plot", "npan", nl_set_npn); snis_nl_add_dictionary_verb("plot", "plot", "npnq", nl_set_npnq); snis_nl_add_dictionary_verb("lay in", "lay in", "npn", nl_set_npn); snis_nl_add_dictionary_verb("lay in", "lay in", "npan", nl_set_npn); snis_nl_add_dictionary_verb("lay in", "lay in", "npnq", nl_set_npnq);
snis_nl_add_dictionary_verb("set" , "set", "npn", nl_set_npn); /* set a course for the planet */
snis_nl_add_dictionary_verb("set","set" , "npn", nl_set_npn); /* set a course for the planet */
snis_nl_add_dictionary_verb("set", "set","npn" , nl_set_npn); /* set a course for the planet */
snis_nl_add_dictionary_verb("set", "set", "npn",nl_set_npn ); /* set a course for the planet */
Syntax of verb, denoted by characters. 'n' - single noun (or pronoun) 'l' - one or more nouns (or pronoun) 'p' - preposition 'P' - pronoun (unsubstitued, in most cases you probably want 'n' for noun.) This is for cases like "it" in "how far is it to earth?" The word "it" doesn't have or need any explicit antecedent. 'q' - quantity, that is to say, a number. 'a' - adjective 'x' - auxiliary verb (be, do, have, will, shall, would, should, can, could, may, might, must, ought, etc. )
static void my_verb_callback_fn(void *context, int argc, char *argv[], int pos[], union snis_nl_extra_data extra_data[])
static uint32_t my_lookup_function(void *context, char *word);
snis_nl_add_external_lookup(my_lookup_function);
uint32_t noun_id = extra_data[noun].external_noun.handle
float value = extra_data[number].number.value;
snis_nl_parse_natural_language_request(NULL, "set the warp drive power to fifty percent");