package tts2;
/**
*
* @author ce00582
*/
import javax.sound.sampled.*;
import com.sun.speech.freetts.*;
import com.sun.speech.freetts.audio.*;
public class pro {
public static void main(String[] args) {
String message = "Hello world! This is a test. This is a test.";
// FreeTTSのメインとなるクラスを取得
VoiceManager vm = VoiceManager.getInstance();
// 使えそうな Voice オブジェクトのリストを取得
// Each call to getVoices() creates a new instance of each voice.
Voice[] vlist = vm.getVoices();
for(int i=0; i<vlist.length; i++){
Voice v = vlist[i];
String baseName = "20071103_freetts_" + v.getName(); // the base name of the audio file
AudioFileFormat.Type type = AudioFileFormat.Type.WAVE;
SingleFileAudioPlayer sfap = new SingleFileAudioPlayer(baseName, type);
v.allocate();
// 音量を設定
v.setVolume(1.0f); // 0 to 1.0
v.setAudioPlayer(sfap);
// デフォルトの速度で読み上げる
v.speak(message);
// 半分の速さにして読み上げる
v.setRate(v.getRate() / 2.0f);
v.speak(message);
// 音声処理を終了
v.deallocate();
sfap.close();
}
}
}
最終更新:2011年08月19日 06:21