Exemple #1
0
  private void sayPhrase(SpeechTMS5220 tms5220, int addr, boolean wait)
      throws InterruptedException {
    if (wait) {
      // wait for previous phrase to end
      int stat;
      while (true) {
        stat = tms5220.read() & TMS5220Consts.SS_BL + TMS5220Consts.SS_TS;
        if ((stat & TMS5220Consts.SS_TS) == 0 || stat == 0 /* (stat & TMS5220Consts.SS_BL) != 0*/)
          break;
        //			if ((stat & TMS5220Consts.SS_BL) != 0)
        //				break;
        Thread.sleep(10);
      }
    } else {
      Thread.sleep((long) (Math.random() * 30 + 10));
    }

    // read to reset addr pointers
    tms5220.command((byte) 0x10);
    // set phrase addr
    // tms5220.setAddr(addr);

    for (int i = 0; i < 5; i++) {
      tms5220.command((byte) (0x40 | ((addr >> (i * 4)) & 0xf)));
    }

    // speak
    tms5220.command((byte) 0x50);

    if (wait) {
      while ((tms5220.read() & TMS5220Consts.SS_TS) != 0) {
        Thread.sleep(100);
      }
    }
  }
Exemple #2
0
  /**
   * @param tms5220
   * @param s
   * @throws InterruptedException
   */
  private void sayDirect(SpeechTMS5220 tms5220, short[] s) throws InterruptedException {

    // wait for previous phrase to end
    while ((tms5220.read() & TMS5220Consts.SS_TS) != 0) {
      Thread.sleep(10);
    }

    // speak external
    tms5220.command((byte) 0x60);

    int toCopy = 16;
    for (int idx = 0; idx < s.length; ) {
      for (int cnt = 0; cnt < toCopy && idx < s.length; cnt++) {
        tms5220.write((byte) s[idx++]);
      }
      toCopy = 8;

      if (idx >= s.length) break;

      while ((tms5220.read() & TMS5220Consts.SS_BL + TMS5220Consts.SS_TS) == TMS5220Consts.SS_TS) {
        Thread.sleep(1);
      }
    }
  }
Exemple #3
0
  private void run() throws Exception {

    ISettingsHandler settings = new BasicSettingsHandler();

    DataFiles.addSearchPath(settings, "/usr/local/src/v9t9-data/roms");
    DataFiles.addSearchPath(settings, "l:/src/v9t9-data/roms");
    IMachine machine = new StandardTI994AMachineModel().createMachine(settings);
    SpeechTMS5220 tms5220 = (SpeechTMS5220) machine.getSpeech();

    settings.get(ISpeechChip.settingLogSpeech).setInt(1);
    settings.get(ISpeechChip.settingTalkSpeed).setDouble(1.0);

    LPCSpeech speech = tms5220.getLpcSpeech();
    speech.init();

    machine.start();
    machine.setPaused(true);

    final FileOutputStream fos = new FileOutputStream("/tmp/speech.raw");

    SpeechDataSender sender = new SpeechDataSender(8000, 20);
    sender.setOutputStream(fos);

    tms5220.addSpeechListener(sender);

    // reset
    tms5220.command((byte) 0x70);

    // "test" from TEII
    sayDirect(
        tms5220,
        new short[] {
          0, 0x10, 0x80, 0x1d, 0xc5, 0x3, 0x70, 0xac, 0x87, 0x1, 0x52, 0x28, 0x2e, 0x69, 0xcc, 0xee,
          0x1a, 0x35, 0x79, 0xa5, 0x31, 0xbb, 0x6b, 0xd4, 0xe4, 0x9d, 0xae, 0x34, 0x66, 0x4b, 0x89,
          0x1c, 0x3d, 0x52, 0x57, 0x35, 0x2c, 0xbb, 0xb4, 0x7, 0x8, 0xf0, 0x53, 0x84, 0x4, 0x34,
          0x60, 0x80, 0x9f, 0x32, 0x3d, 0x10, 0x80, 0x9f, 0xdc, 0x24, 0, 0, 0xe, 0x58, 0xc2, 0x3,
          0x4, 0x58, 0xc2, 0xfc, 0x1
        });

    if (true) {
      // should exit quickly (or not...)
      // sayPhrase(tms5220, 0xfff0);

      sayPhrase(tms5220, 0x351a); // HELLO
      sayPhrase(tms5220, 0x71f4); // UHOH

      sayDirect(tms5220, THAT_IS_RIGHT);

      sayPhrase(tms5220, 0x4642); // MORE

      sayDirect(tms5220, THAT_IS_RIGHT);
      sayDirect(tms5220, THAT_IS_RIGHT);
    }

    ///

    // bad usage, no waiting -- should delay anyway!
    //		sayPhrase(tms5220, 0x1D82);	// CHECK
    //		sayPhrase(tms5220, 0x2612);	// DRAW
    //		sayPhrase(tms5220, 0x1c48);	// BYE
    //		sayPhrase(tms5220, 0x3148);	// GOODBYE

    if (true) {
      sayPhrase(tms5220, 0x1a42, false); // BE
      sayPhrase(tms5220, 0x4642, false); // MORE
      sayPhrase(tms5220, 0x51b3, false); // POSITIVE
      sayPhrase(tms5220, 0x1714, false); // ABOUT
      sayPhrase(tms5220, 0x69b6, false); // THE1
      sayPhrase(tms5220, 0x208b, false); // CONNECTED
      sayPhrase(tms5220, 0x2034, false); // COMPUTER
      sayPhrase(tms5220, 0x24ea, false); // DOING
      sayPhrase(tms5220, 0x2599, false); // DOUBLE
      sayPhrase(tms5220, 0x6e69, false); // TIME
      sayPhrase(tms5220, 0x1769, false); // AFTER
      sayPhrase(tms5220, 0x70ce, false); // TWELVE
      sayPhrase(tms5220, 0x4e66, false); // P
      sayPhrase(tms5220, 0x4233, false); // M

    } else {
      //			sayPhrase(tms5220, 0x70ce, false);	// TWELVE
      //			sayPhrase(tms5220, 0x4e66, false);	// P
    }
    Thread.sleep(2000);

    fos.close();
    // System.exit(0);
  }