Menu

#5 initial url resolved

open
nobody
None
5
2008-09-01
2008-09-01
Anonymous
No

/**
* Copyright 2003 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and
* redistribution of this file, and for a DISCLAIMER OF ALL
* WARRANTIES.
*/
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;

/**
* Simple program to demonstrate the use of the FreeTTS speech
* synthesizer. This simple program shows how to use FreeTTS
* without requiring the Java Speech API (JSAPI).
*/
public class FreeTTS {

public FreeTTS()
{
String voiceName = "kevin16";;

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

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

/* Allocates the resources for the voice.
*/
helloVoice.allocate();

helloVoice.setVolume(volumeRate);

helloVoice.setPitch(pitchRate);

helloVoice.setRate(speakingRate);

}

public synchronized static void speakText(String text) {

/* String voiceName = "kevin16";;

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

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

/* Allocates the resources for the voice.
*/
/* helloVoice.allocate();

helloVoice.setVolume(volumeRate);

helloVoice.setPitch(pitchRate);

helloVoice.setRate(speakingRate);

*/

/* Synthesize speech.
*/
helloVoice.speak(text);

/* Clean up and leave.
*/
// helloVoice.deallocate();

}

public void setVolume(float sV)
{
volumeRate=sV;
helloVoice.setVolume(volumeRate);
}

public void setSpeakingRate(float sR)
{
speakingRate=sR;
helloVoice.setRate(speakingRate);

}
public void setPitch(float sP)
{
pitchRate=sP;
helloVoice.setPitch(pitchRate);
}
public void setRange(float sR)
{
rangeRate=sR;
helloVoice.setRate(speakingRate);
}

private static VoiceManager voiceManager;
private static Voice helloVoice;
private static float volumeRate=10;
private static float speakingRate=150;
private static float rangeRate=12;
private static float pitchRate=100;
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.