We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › FreeTTS - text to speech in Processing
Page Index Toggle Pages: 1
FreeTTS - text to speech in Processing (Read 10633 times)
FreeTTS - text to speech in Processing
Mar 1st, 2008, 2:34am
 
Hello all,

I'm trying to use FreeTTS in processing.  I don't really know where to start with the API for FreeTTS.  I was wondering if anyone had tried this already and maybe has some example code.  I've got all the libraries copied over and I can run the FreeTTS java demos.  I just don't understand how java syntax translates to processing syntax.  I wish there was an import function.
Re: FreeTTS - text to speech in Processing
Reply #1 - Mar 5th, 2008, 3:35pm
 
Hello ohtravoiso,

Ok sending short tutor how to make processing speaking..

1. Download FreeTTS - java speech synthetiser

2. Put all of jars inside the CODE dir in your sketch folder, should looks like this:

Quote:
+---code
|       cmudict04.jar
|       cmulex.jar
|       cmutimelex.jar
|       cmu_time_awb.jar
|       cmu_us_kal.jar
|       en_us.jar
|       freetts.jar
|       jsapi.jar


3. Try my messy class called "Basnik" :
Code:
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
import com.sun.speech.freetts.audio.JavaClipAudioPlayer;

public class Basnik {
String voiceName = "kevin16";
VoiceManager voiceManager;
Voice voice;

Basnik(String name){
voiceName = name;
this.setup();
}

void listAllVoices() {
System.out.println();
System.out.println("All voices available:");
VoiceManager voiceManager = VoiceManager.getInstance();
Voice[] voices = voiceManager.getVoices();
for (int i = 0; i < voices.length; i++) {
System.out.println(" " + voices[i].getName()
+ " (" + voices[i].getDomain() + " domain)");
}
}

void setup() {
listAllVoices();
System.out.println();
System.out.println("Using voice: " + voiceName);

voiceManager = VoiceManager.getInstance();
voice = voiceManager.getVoice(voiceName);

voice.setPitch(1.75);
voice.setPitchShift(0.75);
// voice.setPitchRange(10.1); //mutace
voice.setStyle("casual"); //"business", "casual", "robotic", "breathy"

if (voice == null) {
System.err.println(
"Cannot find a voice named "
+ voiceName + ". Please specify a different voice.");
System.exit(1);
}
voice.allocate();
}

void mluv(String _a){

if(_a==null){
_a= "nothing";
}
voice.speak(_a);

}

void exit(){
voice.deallocate();
}
}


4. and use a class like this: Code:

Basnik verlaine;

void setup(){
verlaine = new Basnik("kevin16");
verlaine.mluv("hello, ohtravioso, do you hear me?") ;
}


modify as you need
.. wish you good luck!

kof
Re: FreeTTS - text to speech in Processing
Reply #2 - Mar 7th, 2008, 1:28pm
 
hehe thats great... thx for the mini tutorial.
Re: FreeTTS - text to speech in Processing
Reply #3 - May 9th, 2008, 5:51pm
 
I'm working on a project(experimenting) that uses speech in Processing. I tried the tutorial on here about using FreeTTS and I cam up with this error
ERROR:::
The import"com/sun/FreeTTS/Voice" is not valid, since it does not name a type in a package.

Can any one help me out
Re: FreeTTS - text to speech in Processing
Reply #4 - May 9th, 2008, 6:54pm
 
hi lali,
first think, make sure you put all of the jars inside "code" directory of your sketch.

.. another problem can be caused by the version of your java machine, if you are using processing with bundled java inside (1.4), try to download "expert" version of processing and try to run with latest java, or at least java 1.5 ..
..but in case of your error message, it doesnt makes much sense for me.

example has not been very tested yet, maybe FreeTTS has some update which changes some of its behaviour, i am not sure, but you can try to download older freeTTS package, i think "1.2beta" should work...  

good luck,
kof
Re: FreeTTS - text to speech in Processing
Reply #5 - May 12th, 2008, 4:01am
 
thank you, for your reply. The problem was calling the classes . I figured it out and it works now. cool tutorial, Thanks.
Re: FreeTTS - text to speech in Processing
Reply #6 - Oct 14th, 2008, 1:19am
 
Can someone post an example of how they imported the classes? I'm having issues getting processing to import the freetts classes in code.
Re: FreeTTS - text to speech in Processing
Reply #7 - Jun 30th, 2009, 9:11pm
 
hello lali...m a beginner....can u pls send me a running code for text to speech....when i run the demos it works fine....but i am not able to run my own applications....please send me all the details about freetts(which jar files te be copied,classpaths to set.etc,etc)...just wanna run a simle helloworld example.....plssssssssssssssssssssssssssss


thanks
Re: FreeTTS - text to speech in Processing
Reply #8 - Jun 30th, 2009, 9:46pm
 
Hi,

i wrote a wrapper library for freetts,
this should simplify things a bit.

http://www.local-guru.net/blog/pages/ttslib

there is also a simple but working code example.

the only restriction freeTTS has is, it doesn't work in applets only in applications
Re: FreeTTS - text to speech in Processing
Reply #9 - Jul 6th, 2009, 12:07pm
 
I got TTSlibary working but i would like to change the voice. is there any way for that?
Re: FreeTTS - text to speech in Processing
Reply #10 - Oct 2nd, 2009, 7:38am
 
i'm trying to use FreeTTS the way kof described, but I keep getting this error:

Quote:
Can't find diphone hh-t
Can't find diphone hh-t


I've tried a few versions of FreeTTS: 1.1.2, 1.2, 1.2.2, 1.2beta, and 1.2beta2. I'm not using ttslib because I'd like to have a little more control. Specifically, I'd like to convert text to a string of phonemes, then doing something else besides speech gen with them.

Any clues on that error message?

matt
Re: FreeTTS - text to speech in Processing
Reply #11 - Apr 10th, 2010, 7:00pm
 
Hi everyone,

Thanks so much for putting this stuff up!  The Processing community is amazing.

I'm a bit of a novice and I'm having trouble... I was able to get Guru's wrapper to work, but I want to run the program as written by kof to get at the pitch, voices, etc.  

Here's what I did:
    downloaded the FreeTTS-1.2 folder
    copied the unzipped folder to my Processing -> Libraries folder
    created a new sketch and copied kof's "messy class called 'Basnik'" code
    added the .jar files to that sketch
    tried to run the sketch... fail


First off, I don't know what to do with the other class definition:
Code:
Basnik verlaine;

void setup(){
verlaine = new Basnik("kevin16");
verlaine.mluv("hello, ohtravioso, do you hear me?") ;
}


The error message I had gotten was:
"Cannot parse error text: File /var/folders/cA/cAk9KFBcEd00oOQqVw4LYE+++TI/-Tmp-/build8236272106602607481.tmp/B
asnik.java is missing"

I'd really appreciate any help.  I bet I'm just missing some basic step... don't totally understand the syntax of how the sketches are calling the .jar libraries and what happens behind the scenes, so it's hard to debug my own problem.  

Thanks so much!

Re: FreeTTS - text to speech in Processing
Reply #12 - Apr 11th, 2010, 4:44am
 
dGoligorsky wrote on Apr 10th, 2010, 7:00pm:
Hi everyone,

Here's what I did:
    downloaded the FreeTTS-1.2 folder
    copied the unzipped folder to my Processing -> Libraries folder
    created a new sketch and copied kof's "messy class called 'Basnik'" code
    added the .jar files to that sketch
    tried to run the sketch... fail



FreeTTS is not wrapped as a Processing library so, as mentioned in kof's instruction, you're supposed to create a folder called "code" in your sketch folder and paste into it the jar files that you'd find in the FreeTTS zip.

dGoligorsky wrote on Apr 10th, 2010, 7:00pm:
First off, I don't know what to do with the other class definition:
Code:
Basnik verlaine;

void setup(){
verlaine = new Basnik("kevin16");
verlaine.mluv("hello, ohtravioso, do you hear me?") ;
}



This needs to be the main file in the pde, aka what you shall paste into the IDE upon creating the new Sketch. Once it is done, you shall create a new Tab, call it "Basnik" and paste into that tab the Basnik class definition as provided by kof.

dGoligorsky wrote on Apr 10th, 2010, 7:00pm:
The error message I had gotten was:
"Cannot parse error text: File /var/folders/cA/cAk9KFBcEd00oOQqVw4LYE+++TI/-Tmp-/build8236272106602607481.tmp/B
asnik.java is missing"


As the end of the message implies (Basnik.java is missing), the IDE tries to find the definition for the Basnik class, hence why you shall create a new Tab called Basnik in the IDE.

HTH,

Pierre
Re: FreeTTS - text to speech in Processing
Reply #13 - Apr 11th, 2010, 4:55am
 
Or, alternatively, you shall try and use Guru's wrapper at http://www.local-guru.net/blog/pages/ttslib mentioned above (http://processing.org/discourse/yabb2/num_1204335245.html#8) with the caveat that it wouldn't work if you try to deploy it as part of an applet.
Re: FreeTTS - text to speech in Processing
Reply #14 - Apr 12th, 2010, 11:15am
 
tanepierre, it all works now, thanks!

Now I understand that I need to run that short code calling the class defined in the other tab.

Thanks for you help!
Page Index Toggle Pages: 1