Hi,
I try to run this code (very ugly for now) :
sentences = str(config.nlu.sentences_ini)
# Read sentences
with io.StringIO() as ini_file:
with open(sentences, "r") as sentences_file:
ini_file.write(sentences_file.read())
print("", file=ini_file)
ini_text = ini_file.getvalue()
intents = rhasspynlu.parse_ini(ini_text)
#intents = rhasspynlu.parse_ini(open(str(config.nlu.sentences_ini), "r").read())
sentences, replacements = rhasspynlu.ini_jsgf.split_rules(intents)
slot_replacements = rhasspynlu.slots.get_slot_replacements(intents, slots_dirs=[self._slots_dirs], slot_programs_dirs=[self._slot_programs_dirs])
for slot_key, slot_values in slot_replacements.items():
replacements[slot_key] = slot_values
for intent_sentences in sentences.values():
for sentence in intent_sentences:
rhasspynlu.jsgf.walk_expression(sentence, rhasspynlu.numbers.number_range_transform, replacements=replacements)
for intent_sentences in sentences.values():
for sentence in intent_sentences:
rhasspynlu.jsgf.walk_expression(
sentence,
lambda w: rhasspynlu.numbers.number_transform(w, "en"),
replacements=replacements,
)
self._graph_json = rhasspynlu.sentences_to_graph(sentences, replacements=replacements)
I have the following sentences.ini :
[mediaplayer]
enable{value:true} (subtitles|subtitle){action:enable_subtitle}
disable{value:false} (subtitles|subtitle){action:enable_subtitle}
(mute {action:set_mute}) {value:true}
(unmute {action:set_mute}) {value:false}
(previous (subtitle|subtitles)){action:previous_subtitle}
(next (subtitle|subtitles)){action:next_subtitle}
(previous audio){action:previous_audio}
(next audio){action:next_audio}
(previous chapter){action:previous_chapter}
(next chapter){action:next_chapter}
(play|pause|resume|continue){action:play_pause}
stop{action:stop}
set volume{action:set_volume} (1..100){value}
I have the number slot_programs under <path_to_profile>/slot_programs/rhasspy/
Slots works well under <path_to_profile>/slots/
When the program run sentences_to_graph(sentences, replacements=replacements), it raise the error “AssertionError: Missing slot $rhasspy/number,1,100,1”.
Can someone help me ?