音声合成でHello, world!
Posted feedbacks - Java
FreeTTSというライブラリを使ってみました。"Hello, world!"だとちょっと変な感じになるので、"Hello world!"にしています。
see: FreeTTS 1.2 - A speech synthesizer written entirely in the Java(TM) programming language
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
public class Speaker {
public static void main(String[] args) {
args = args.length == 0 ? new String[] { "Hello world!" } : args;
StringBuffer message = new StringBuffer();
for (int i = 0; i < args.length; i++) {
message.append(args[i]);
message.append(' ');
}
VoiceManager voiceManager = VoiceManager.getInstance();
Voice helloVoice = voiceManager.getVoice("kevin16");
System.out.printf("%s say \"%s\".%n", helloVoice.getName(), message);
helloVoice.allocate();
helloVoice.setVolume(100.0f);
helloVoice.speak(message.toString());
helloVoice.deallocate();
}
}
|


にしお
#3415()
Rating4/4=1.00
使用したライブラリはタグでつけてください。またOSに依存する場合もタグでつけてください。日本語文字列も発音できることが好ましいですが、必須ではありません。
以下はサンプルです。
>>> say("Hello, world!") >>> say("con nitch were") # 「こんにちは」 >>> say("daw cat coo org, sole what program mar know tum yen know Colosseum death")[ reply ]