import t2s.son.TextReader; |
ReaderTextReader = new ReaderText("Hello"); |
player.playAll(); |
reader.setText("I am a text-to-speech program"); |
import t2s.son.TextReader;
public class Synthese_Vocale{
public static void main(String[] args) {
ReaderTextReader = new ReaderText("hello");
player.playAll();
reader.setText("I'm a speech synthesizer, who are you?");
player.playAll();
}
}
VoiceManager voiceManager = VoiceManager.getInstance(); // Create a list of voices Voice[] voice = voiceManager.getVoices(); //Each voice has properties, you can browse the list to find the voice as needed. // allocate resources for this voice voice [x].allocate(); |
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
public class Synthese_Vocale {
/**
* How to display all voices
*/
public static void voicelist() {
System.out.println("All available voices:");
VoiceManager voiceManager = VoiceManager.getInstance();
Voice[] voice = voiceManager.getVoices();
for (int i = 0; i < voice.length; i++) {
System.out.println(" " + voice[i].getName()
+ " (" + voice[i].getDomain() + " domain)");
}
}
public static void main(String[] args) {
/*Method that allows the display of all available voices*/
voicelist();
String VoiceName = "kevin";
System.out.println("\nVoice used: " + VoiceName);
/* The VoiceManager manages all voices for FreeTTS
*/
VoiceManager voiceManager = VoiceManager.getInstance();
/*Load voice
*/
Voice = voiceManager.getVoice(VoiceName);
/*If the voice name does not exist, then error
*/
if (voice == null) {
System.err.println(
"The voice "
+ voicename +". is not recognized please try another name.");
System.exit(1);
}
/* Load resources whose voice uses
*/
voice.allocate();
/* synthesize speech
*/
voice.speak("hello world");
voice.speak("how are you today");
voice.speak("I am a programmer");
/* unallocate
*/
voices.deallocate();
/*program completed successfully
*/
System.exit(0);
}
}
Please disable your ad blocker and refresh the window to use this website.