I figured out how to do this, you just need to use SingleFileAudioPlayer to pass the file name and file type for which you want the sample declaration to be as follows:
audioPlayer = new SingleFileAudioPlayer("output",Type.WAVE);
Now you need to attach the SingleFileAudioPlayer object to your VoiceManager object: for example.
helloVoice.setAudioPlayer(audioPlayer);
Now use:
hellovoice.speak("zyxss");
This will save the file with what they say there. Do not forget to close the audio player, otherwise the file will not be saved. Put audioPlayer.close(); before leaving.
Here is the full working code that will upload the file to the C directory
import com.sun.speech.freetts.FreeTTS; import com.sun.speech.freetts.Voice; import com.sun.speech.freetts.VoiceManager; import com.sun.speech.freetts.audio.AudioPlayer; import com.sun.speech.freetts.audio.SingleFileAudioPlayer; import javax.sound.sampled.AudioFileFormat.Type; public class FreeTTSHelloWorld { public static void main(String[] args) {
Pranay airan
source share