Hello Friends,
Please read my previous post before using it.
If you run previous program then you find output is:
1. alan
2. kevin
3. kevin16
These output name is the voice file name which is using in FreeTTS Java API.
FileReader :
In this case you write any paragraph or word in a file and read it using this program. This program read that file and play them.
Source code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tts;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
import java.io.IOException;
/**
*
* @author sandy
*/
public class FileSpeaker {
public static void main(String[] arg) throws IOException,Exception
{
String voicename = "kevin";
VoiceManager voicemgr = VoiceManager.getInstance();
Voice voice = voicemgr.getVoice(voicename);
voice.setPitch((float)6.00);
voice.setPitchShift((float) .002);
voice.setPitchRange((float) 0.05);
voice.setStyle("business");
//allocate the resouce for the voice
voice.allocate();
// create input stream for the file
InputStream in = new FileInputStream(new File("D:/sample.txt"));
voice.speak(in);
voice.deallocate();
}
}
Sample.txt
Hello friends my name is Sandeep.
Please read my previous post before using it.
If you run previous program then you find output is:
1. alan
2. kevin
3. kevin16
These output name is the voice file name which is using in FreeTTS Java API.
FileReader :
In this case you write any paragraph or word in a file and read it using this program. This program read that file and play them.
Source code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tts;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
import java.io.IOException;
/**
*
* @author sandy
*/
public class FileSpeaker {
public static void main(String[] arg) throws IOException,Exception
{
String voicename = "kevin";
VoiceManager voicemgr = VoiceManager.getInstance();
Voice voice = voicemgr.getVoice(voicename);
voice.setPitch((float)6.00);
voice.setPitchShift((float) .002);
voice.setPitchRange((float) 0.05);
voice.setStyle("business");
//allocate the resouce for the voice
voice.allocate();
// create input stream for the file
InputStream in = new FileInputStream(new File("D:/sample.txt"));
voice.speak(in);
voice.deallocate();
}
}
Sample.txt
Hello friends my name is Sandeep.