wit-ai / wit-unity

Wit-Unity is a Unity C# wrapper around the the Wit.ai rest APIs and is a core component of Voice SDK.
Other
78 stars 20 forks source link

Is it possible to only use one intent at a time? #83

Open luketurnerdev opened 1 year ago

luketurnerdev commented 1 year ago

Hi there!

I have two intents setup in my Wit.ai configuration: reciteWord and reciteSentence.

However, some words (e.g., "I") are also contained in phrases (e.g., "I Like Pizza"). Wit then matches the "I" as a recitedWord (entity) and ignores the recitedSentence, which is what I want. wit

The intent in the response matcher is set to recite_sentence (see pic) but the JSON response that comes back still only matches recitedWords.

Also attached is my entity setup in Wit. wit2

Any help would be appreciated!

ChrisyShine commented 1 year ago

@luketurnerdev Can you share the wit app id?

luketurnerdev commented 1 year ago

@ChrisyShine 471818378315989

ChrisyShine commented 1 year ago

If the sentence is for a purpose, why do you need to annotate the whole sentence as an entity? Is the intent recite_sentence enough? So the annotation will be something like: The whole sentence is annotated as recite_sentence and some words within the sentence is annotated with recitedWords entities.

luketurnerdev commented 1 year ago

@ChrisyShine Thank you for your response. I have removed recitedSentence as an entity, but i'm unsure how to access the callback for an intent.

Here is the current flow: 1) User speaks a sentence. 2) Wit recognizes the sentence as an intent (see pic) image 3) I have added both the name of the intent, and the words uttered under Value Matchers (see pic): image 4) I have added a callback method to On Multi Value Event 5) Callback is never triggered.

Are intents handled differently than entities (perhaps formatted value events instead)? Please help me understand how to setup this callback to be triggered in much the same way.

Your help is much appreciated!

yolanother commented 1 year ago
image

If you only want to match on one intent you should use the intent value above instead of a value matcher for the intents. Otherwise you'll need to make sure your first value matcher is set to require value.

This is likely what you are after:

image
yolanother commented 1 year ago

I also noticed something else about your screenshots above. The paths you are using in your response matchers are incorrect and won't match values. I'd recommend using the Understanding Viewer to add matchers to the component as in the following screenshot.

image

If you wanted to process multiple intents you could do something like the following:

image

Note: if you want the value to match and be required to match you need to check "Content Required"

luketurnerdev commented 1 year ago

Hi @yolanother , thanks very much for your response.

I have setup my Response Matcher as closely as I could to yours:

image

However,

1) I notice that several options are not available, e.g., path, comparison method, etc. I have updated to the latest version of this package using package manager and am running Windows 11. I'm not sure where these other options are from?

2) I also am unsure how to access the intent once it has been registered. Previously I put a callback into On Multi Value Event (see pic), but clearly the intent callbacks must be registered elsewhere? I would expect to see something like On Value Match (String), but no such option exists. I'd like to be able to use a function like the following, except with only a single string value instead of a String[] array:

image

Apologies for the many questions, I just couldn't seem to find the documentation for this, and the Shapes tutorial only covered the use of entities.

yolanother commented 1 year ago

It is odd that you can't see the additional fields, they are in all versions of VSDK. Do you have any additional assets installed that effect how UI is rendered like Odin? What version of Unity are you running?

The intent won't show up in the values string array, you will need to use the value matcher and its event above that to get the value. There is another way to do it. You could match with a [MatchIntent] attribute instead of using a value matcher. If you do that you can get direct access to the wit response in your method.

EX: [MatchIntent("recite_sentence")] public void StartWordCheck(WitResponseNode response) { var transcription = response.GetTranscription(); }

luketurnerdev commented 1 year ago

Thanks for the quick response, I am running Unity 2022.1.4f1 and don't have any additional UI addons. I deleted and reinstalled the latest version of Wit from the Github repo, didn't seem to help.

I don't seem to have a place to enter callback events for intents in the GUI that I can see, but calling it from the script worked with your example, thank you!

Is there a full API documentation somewhere? Or at least somewhere in the source code you can point me to where the main intent functions are defined? Would be very helpful.

Thanks again!

yolanother commented 1 year ago

Ok, we'll give 2022.1.4 a try. I would recommend using Voice SDK instead of wit-unity directly. Wit-unity is a submodule of Voice SDK and is meant for bleeding edge development. It won't always build.

Docs: https://developer.oculus.com/documentation/unity/voice-sdk-overview/ VSDK Download: https://developer.oculus.com/downloads/package/oculus-voice-sdk/