ttslib for processing
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");
}
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
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
How would you change voices with this library? Is it exposed anywhere?
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
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.
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!"); }
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 () {
tts.setPitchRange(-10); tts.setPitchShift(-3);
}
// 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(); }
}
is it possible to change the volume/sound with tts. I tried setVolume but it doesnt work...
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