Open DylanPhuah opened 1 month ago
` import java.util.Locale; import java.util.Scanner;
import javax.speech.Central; import javax.speech.synthesis.Synthesizer; import javax.speech.synthesis.SynthesizerModeDesc;
public class TextToSpeech {
private static final String VOICES_KEY = "freetts.voices";
private static final String VOICE_VALUE = "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory";
private static final String CENTRAL_DATA = "com.sun.speech.freetts.jsapi.FreeTTSEngineCentral";
public static void main(String[] args) {
try {
//Scanner sc = new Scanner(System.in);
//String data = sc.nextLine();
System.setProperty(VOICES_KEY,VOICE_VALUE);
String data = "Arabella's got some interstellar gator skin boots";
Central.registerEngineCentral( CENTRAL_DATA);
Synthesizer sy = Central.createSynthesizer(new SynthesizerModeDesc(Locale.US));
sy.allocate();
sy.resume();
sy.speakPlainText(data, null);
sy.waitEngineState(Synthesizer.QUEUE_EMPTY);
sy.deallocate();
} catch (Exception e) {
System.out.println("Hello, World!");
}
}
}`
Use this snippet here, and this video https://www.youtube.com/watch?v=SV4cP27TvD8
We should look into how we would go about making a Java program read out text given to it. People assigned to this should be ready to go by next week.