Last active
March 2, 2021 16:56
-
-
Save colelawrence/affafdce9a0994e39b9b4dcfba57a89a to your computer and use it in GitHub Desktop.
unknown realtalk sample -- not sure if this would work with current realtalk system, just playing around...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Voice recognizer | |
| -- `_ speaking is heard _` | |
| When /person/ speaking is heard /speech/: | |
| -- word { confidence, lowercase, pauses_after } | |
| local words = identify(speech) | |
| -- `_ was asked if they meant _ of _` | |
| When (person) was asked if they meant /option index/ of /possible_choices/, | |
| -- `_ as _ is _` | |
| /yes_or_no/ as (nlp_yes_no(words)) is (not_nil): | |
| if yes_or_no then | |
| -- yes, so execute choice | |
| local choice = possible_choices[index] | |
| if choice ~= nil then | |
| -- `_ wishes _` | |
| Claim (person) wishes (choice). | |
| end | |
| else | |
| clarify(person, index + 1, possible_choices) | |
| end | |
| Otherwise: | |
| local choices = find_choices(words) | |
| if #choices == 0 then | |
| -- triggers speaker to say something to person | |
| Wish (you) told (person) "I could not understand what you meant". | |
| else | |
| -- identify choice | |
| local threshold = 0.3 | |
| local possible_choices = {} | |
| local understood_choices = {} | |
| for _, item in ipairs(choices) | |
| if item.distance > threshold then | |
| -- too far | |
| table.insert(possible_choices, item) | |
| else | |
| -- understood as | |
| table.insert(understood_choices, threshold) | |
| end | |
| if #understood_choices > 0 then | |
| for _, choice in ipairs(understood_choices) | |
| -- need to pass person along the chain as a source in case further questions come up | |
| -- there may be multiple sources, but we can always narrow down the source by using a When. | |
| Claim (person) wishes (choice). | |
| end | |
| else | |
| -- ask for clarification | |
| clarify(person, 1, possible_choices) | |
| end | |
| end | |
| End | |
| end | |
| End | |
| function clarify(person, index, possible) | |
| local choice = possible[index] | |
| if choice == nil then | |
| Wish (you) told (person) "I'm sorry, I don't understand". | |
| else | |
| Where (choice) has /statement/: | |
| Wish (you) asked (person) ("Would you like "..statement). | |
| -- move the state machine forward | |
| -- `_ was asked if they meant _ of _` | |
| Claim (person) was asked if they meant (index) of (possible). | |
| Otherwise: | |
| Log (choice) did not have a statement. | |
| clarify(person, index + 1, possible) | |
| End | |
| end | |
| end |
Author
Author
I'm trying to think about the system as an asynchronous claim/wish paradigm which could seamlessly integrate with a person. I would like a system which could wish "for the lights to be off", and a person to be able to turn the lights off and claim "the lights are off"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could there be a central context which runs on each execution loop?
Would
WhensandClaimsbe queued up in some way? and evaluated on each loop?How could you determine if a When/Claim goes out of scope/is ready to be "garbage collected"?
For example,
When (person) was asked if they meant /option index/ of /possible_choices/,is kind of a way we are holding state...