ttslib for processing

Nikolaus Gradwohl2009-05-16T20:31:00+00:00

i have written another library for processing. This time its a wrapper around the freetts library

now processing sketches can have a voice too.

click here to go to the project page.

i cannot present an applet as an example this time, because freetts doesn't work in applets. So i show the example.

import guru.ttslib.*;

TTS tts;

void setup() {
  size(100,100);
  smooth();
  tts = new TTS();
}

void draw() {
  background(255);
  fill(255);
  ellipse( 35, 30, 25, 35 );
  ellipse( 65, 30, 25, 35 );
  fill(0);
  ellipse( 40, 35, 10, 10 );
  ellipse( 60, 35, 10, 10 );
  noFill();
  arc(50,50,50,50,0,PI);

}

void mousePressed() {
  tts.speak("Hi! I am a speaking Processing sketch");
}
Tweet This! submit to reddit Digg! Tags: | 7 comments | no trackbacks

See also:

ttslib installation via the processing PDE
Processing TTSlib version 0.4 released
Processing TTSlib version 0.3 released
Using Mbrola-Voices with the Processing ttslib
My name is 192.168.159.16

Trackbacks

Comments

Leave a response

  1. nicole 2009-12-14T20:25:08+00:00

    How would you change voices with this library? Is it exposed anywhere?

  2. Nikolaus Gradwohl 2009-12-15T01:13:42+00:00

    you can use the TTS( "voicename" ) constructor to switch between the installed voiced by default kevin16 and alan get installed, mbrola voiced should work, but i haven't tried them yet

  3. sam 2011-11-30T17:55:22+00:00

    is there a way to run multiple "speeches" simultaneously? e.g. start speaking a second line before the first is finished?

    with this code...

    void mousePressed() { tts.speak("Hi! I am a speaking Processing sketch"); tts.speak("overlapping speech"); }

    ...it just reads one, then the other.

  4. Cypher 2012-06-09T09:12:03+00:00

    You can have different instances of TTS. These can do different things at once.

    e.g.

    import guru.ttslib.*;

    TTS tts, tts2;

    void setup() { size(100,100); smooth(); tts = new TTS(); tts2 = new TTS(); }

    void draw() { background(255); fill(255); ellipse( 35, 30, 25, 35 ); ellipse( 65, 30, 25, 35 ); fill(0); ellipse( 40, 35, 10, 10 ); ellipse( 60, 35, 10, 10 ); noFill(); arc(50,50,50,50,0,PI);

    }

    void mousePressed() { tts.speak("Hi! I am a speaking Processing sketch"); tts2.speak("No your not!"); }

  5. Cypher 2012-06-09T09:14:57+00:00

    Sorry I was wrong above

    you also need to put the speaking in a separate thread.

    Here is a class to do it

    class Speach extends Thread {

    TTS tts; String talk[] = new String[0]; boolean running; // Is the thread running? Yes or no? PApplet app; // Constructor, create the thread // It is not running by default Speach (PApplet in) { running = false; app = in; }

    // Overriding "start()" void start () {

    // Set running equal to true
    running = true;
    
    //load voice
      tts = new TTS();//fix the voice it sounds kinda weird.
    

    tts.setPitchRange(-10); tts.setPitchShift(-3);

    println("Starting Speach");
    // Do whatever start does in Thread, don't forget this!
    super.start();
    

    }

    // We must implement run, this gets triggered by start() void run () { while (running) { if(talk.length > 0) { if(speach) { tts.speak(talk[0]); talk = subset(talk, 1); } } } }

    void say(String in) { talk = append(talk, app.join(split(in, " "), " ")); }

    // Our method that quits the thread void quit() { running = false; // Setting running to false ends the loop in run() // IUn case the thread is waiting. . . interrupt(); }

    }

  6. Antes 2014-12-30T00:26:26+00:00

    is it possible to change the volume/sound with tts. I tried setVolume but it doesnt work...

  7. João 2017-09-04T12:46:04+00:00

    Hi. I like very much your ttslib Library, and i will like work with it, if i can?.

    where can i have help or talk about that with you? i´m from Portugal Thank you João

Leave a comment