예제 #1
0
 /** Starts listening for words */
 private void startListening() {
   if (wordsRecognizer.microphoneOn()) {
     genImage("clippySearch");
     setClippyTxt("Listening...");
   } else {
     Thread speak = new Thread("No Microphone found.");
     speak.start();
     setClippyTxt("Couldn't find microphone");
     micEnabled = false;
     voiceBtn.setEnabled(false);
   }
 }
예제 #2
0
  /**
   * Initializes the Logic classes in the interface
   *
   * @throws IOException
   * @throws InterruptedException
   */
  private void setup() throws IOException, InterruptedException {
    // Get the configuration from the xml resource
    URL url = WordRecognizer.class.getResource("clippy.config.xml");
    ConfigurationManager cm = new ConfigurationManager(url);
    wordsRecognizer = (WordRecognizer) cm.lookup("dialogManager");
    wordsRecognizer.setGui(this);
    MyBehavior menu = new MyBehavior(this);
    MyBehavior time = new MyBehavior(this);
    MyBehavior music = new MyMusicBehavior(this);
    MyBehavior movie = new MyMovieBehavior(this);
    MyBehavior desktop = new MyDesktopBehavior(this);
    MyBehavior website = new MyWebsiteBehavior(this);
    search = new MyGoogleSearchBehavior(this);

    // Add each menu node to the words to be recognised
    wordsRecognizer.addNode("menu", menu);
    wordsRecognizer.addNode("tell me the time", time);
    wordsRecognizer.addNode("music", music);
    wordsRecognizer.addNode("movies", movie);
    wordsRecognizer.addNode("desktop", desktop);
    wordsRecognizer.addNode("web", website);
    wordsRecognizer.addNode("search", search);
    currentBehavior = menu;

    setHeader("Loading IntelliJ");
    initJIntellitype();

    setHeader("Loading Dialogs");
    wordsRecognizer.allocate();

    setHeader("Running  ...");
    wordsRecognizer.addWordListener(
        new WordsListener() {

          public void notify(String word) {
            updateMenu(word);
          }
        });

    wordsRecognizer.setInitialNode("menu");
    voiceMenu.setWordsRecognizer(wordsRecognizer);
  }