Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Overview

In this tutorial we will describe the steps to create a new character using NPCEditor.
The character created in this example will be organized as follows:

  • initial and final phase of exchange of greetings and thanks.
  • after this, if the user states s/he wants to buy a cake, the agents will help the user buying the cake they want. This phase is structured as a series of yes/no or multiple choice questions the virtual agent asks the user. The answers the user provides will define the type of cake the agent will order for the user.

This is the dialog graph we will be creating:

Steps

  1. Start NPCEditor by starting the Virtual Human Toolkit launcher first and clicking on '<< Advanced' and then on 'Launch' in the NPCEditor row (that is under the 'Agents' section.
  2. Select the menu 'File->New' to start creating a new virtual agent. Save it a 'cake.plist'.
  3. Create a new person called 'cake vendor' under the People tab. This 'person' will handle the initial greeting exchange. Each person created defines what NPCEditor calls a domain. Each domain is associated with a different classifier. A domain can work like a state in a dialog manager, we will see later how to define which utterances are defined in a particular domain and how changing domain (i.e. state) works. Make sure u set both 'first name' and 'last name'. If your domain/person is just one word, you can set the last name or the first name to be a space ot you can split the word into 2 parts, one for the first name and the other for the last name.
  4. :
  5. Now define the connection NPCEditor uses to communicate with the rest of the Virtual Human Toolkit architecture. Select the 'Accounts' tab, then click on 'Add' and select 'Smarbody'. Test the connection by clicking on 'Connect': the button will change to 'Disconnect' and the row corresponding to the NPCEditor in the Launcher will become green. This should be defined once and associated only to one of the defined persons: the one that defines the initial domain.
  6. File__CreateConnection.png
  7. Next select as type of dialog manager 'scriptable' in the 'Conversations' tab. A new 'Dialog Manager' tab next to 'Conversations' will appear containing an initial script for a dialog manager. The script is written in Groovy and can be edited to suit your needs.
  8. File__SelectScriptable.png
  9. Set the parent property of 'cake vendor' to 'Anybody' (default value). This step defines an inheritance hierarchy among the various domains. In this case the 'cake vendor' domain inherits the utterances defined for the 'Anybody' domain.
  10. Create all the other persons defined in the dialog graph above: 'cavities', 'xylitol', 'diabetes', 'cake type', 'sponge cake flavor', 'cheese cake flavor'. Set the parent property of each of them to the 'Anybody' domain.
  11. Create a 'type' and 'speaker' category in the 'Setting' tab. The first is used by the default dialog manager script to handle off topic utterances from the user. The second (speaker) needs to be set for proper communication with the rest of the modules in Virtual Human Toolkit.

  12. File__CreateTypeCat.png
  13. File__CreateSpeakerCat.png
  14. Make sure the 'toss' category is set to be included in the answers and used by the classifier.
  15. File__SetTossCat.png
  16. The previous steps end the setup, from now on we will add the utterances we want the agent to understand and we will define the appropriate answers. To define the reply the agent will give when it doesn't understand what the user said; add a new answer and select the type to be 'opaque'. Then define an appropriate text (e.g. "i didn't understand what you said, try to rephrase it"). For all answers you want the agent to be able to speak and animate, set the speaker to 'brad'.
  17. Next add the various utterances. The first defines the agent's answer to the user's statement 'Hi'. Here leave the type of the answer unset (because it's not an answer to be associated with non understanding). Set the speaker to 'brad' as usual and the domain to 'cake vendor'. On the user pane (the left half) set the text to 'Hi'. Finally click on both newly added utterances (they both become blue) and then set the link strength to 6 to define that the one on the right should be the answer for the utterance on the left. Similarly do for adding the replies for 'thank you' and 'bye'.
  18. File__Utt1.png
  19. Now we will see how to make a change of state when the user says a particular utterance. We will change from 'cake vendor' to 'cavities' when the user says that s/he wants to get a cake from the agent. To do so, in addition to the setup done for the other utterances in the previous step, just set the toss property to the 'cavities' domain.
  20. File__Utt2.png
  21. Follow this procedure and complete all steps as represented in the dialog graph given at the beginning. You can see also the complete /wiki/spaces/VHTK/pages/14582324 file.
  22. Before running the example, remember to train the classifier. Select all the rows in the table in teh tab 'Classifiers'. Then check the box 'Test on training data' (because the training data is too small to be split) and then click on 'Start Training'. You can change the optimization criteria. Also, in this example, the Anybody classifier will fail because it contains no links to learn between user utterances and system answers.
  23. File__Train.png
  24. :If during the testing of the example, you see that the classifier returns multiple answers instead on just the correct one, you can adjust the threshold of that classifier by selecting the classifier in question and double-clicking the threshold displayed, as seen in this screen capture:
  25. File__Threshold.png

Making The New Example The Default One

After creating a new example and saving the .plist file, to make it load automatically every time the NPCEditor is started from the Virtual Human Toolkit launcher is sufficient to modify the NPCEditor launching script that is found in <tt>svn_vhtoolkit/trunk/tools/launch-scripts/run-toolkit-npceditor.bat</tt>.
In that script change the pointer from the default plist file to your new plist file.

Also consider setting the option 'Connect at startup' in the 'People' tab for the person/domain associated with the Smartbody connection.

Note On When The Toss To A New Domain Happens

The tossing to a new domain is decided in the dialog manager script (that can be seen in the dialog manager tab).

The default script tosses after the character has finished saying the utterance (finished=both sound and animation are done, sometime these can be out of sync).
This may cause problems when the user doesn't wait for the character to finish its utterance before submitting the next user's utterance (because the domain will not be yet correctly set when the new user's utterance comes in).

To modify the default behavior and move the tossing from the end of the utterance to the beginning of the utterance, move the two selected lines from the method <tt>npcBehavior_done</tt> to the method <tt>npcBehavior_begin</tt> as displayed in the following image:

File__TossBefore.png

Note On Debugging

To debug the dialog manager script one can add logging instructions. To do that one has to add this import: <tt>import com.leuski.af.Application;</tt> and use the following expression to log something: <tt>Application.getLogger().warning(a.toString());</tt> where <tt>a</tt> is the object we want to print in the log.

The log is saved in <tt>$HOME/AppData/Local/Temp/edu.usc.ict.npc.editor.EditorMain.0</tt>

If you are unsure on the location of the log file, you can use tools like Process Explorer.

An additional way to debug it is by using the debugging capabilities of an IDE. With IntelliJ is easy to import the project directly from the source checked out of the svn repository. It figures out most of the dependencies (but not all). Just try to recompile all projects, and resolve one by one the errors the compile gets (that are unresolved symbol errors) by including in the dependencies of the project, the module that implements the symbols (classes) unresolved.

The <tt>main</tt> method to run to get the NPCEditor is the one in the class <tt>trunk\core\NPCEditor\editor\src\java\edu\usc\ict\npc\editor\EditorMain.java</tt>.

IntelliJ can also debug Groovy together with Java (the dialog manager script is written in Groovy).

To recompile NPCEditor just run <tt>ant</tt> from the directory <tt>trunk\core\NPCEditor</tt>.

If you use this way to debug NPCEditor, you may want to disable the NPCEditor row in the launcher so that only the instance started from IntelliJ is present.

Note On A Different Approach To Keep The Dialog Manager State

Another way to handle state changes is by keeping track of the state in the dialog manager script.
When the user says or types something, the classifier receives it and returns the list of most appropriate answers.
This list is what the expression <tt>List<Map<String,Object>> answers = engine.search(global.domainName, event);</tt>
returns (near the top of the method <tt>public boolean vrSpeech_asr_complete(Event event)</tt>. Each answer is an object of form <tt>Map<String,Object></tt>.

Within the script itself, one can keep a state variable, then the state can be changed based on the list returned by the classifier (i.e. <tt>answers</tt>) and a particular reply can be sent to the virtual agent.
To send a particular reply, we can change the value associated with the key 'ID' of the element in <tt>answers</tt> that we want to send to the virtual agent for speach production and animation.
Each answer in the 'Utterances' tab in the NCPEditor has an 'External ID' column. So, to send the utterance we want, just get it's ID (that is the value of the 'External ID' column, this should have be manually stored in the state variable), then pick one of the objects in <tt>answers</tt>, change the value associated with the key 'ID' to the 'External ID' selected and send the modified object using the <tt>send</tt> method.

  • No labels