Beispiel #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);
      }
    }
  }
Beispiel #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);
      }
    }
  }