?? speechbot.java
字號:
import javax.sound.sampled.AudioFormat;
import org.jibble.pircbot.PircBot;
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.JavaClipAudioPlayer;
public class SpeechBot extends PircBot {
private Voice voice;
public SpeechBot(String name) {
setName(name);
// Choose the voice for the speech synthesizer.
// 選擇語音合成器的話音
String voiceName = "kevin16";
VoiceManager voiceManager = VoiceManager.getInstance();
voice = voiceManager.getVoice(voiceName);
if (voice == null) {
System.out.println("Voice not found.");
System.exit(1);
}
voice.allocate();
// Set up the output format.
// 設(shè)置輸出格式
AudioPlayer voicePlayer = new JavaClipAudioPlayer();
voicePlayer.setAudioFormat(new AudioFormat(8000, 16, 1, false, true));
voice.setAudioPlayer(voicePlayer);
}
// public void onMessage(String channel, String sender, String login,
// String hostname, String message) {
// // Send all IRC messages to the voice synthesizer.
// // 發(fā)送所有的IRC消息到語音合成器
// message = message.trim();
// String input = sender + " on " + channel + " says: " + message;
// voice.speak(input);
// }
public void onMessage(String channel, String sender, String login,
String hostname, String message) {
// Send all IRC messages to the voice synthesizer.
// 發(fā)送所有的IRC消息到語音合成器
message = message.trim();
String input = message;
voice.speak(input);
}
// public static void main(String[] args) throws Exception {
// if (args.length < 2) {
// System.out.println("Usage: java SpeechBot ");
// System.exit(1);
// }
// SpeechBot bot = new SpeechBot("SpeechBot");
// bot.connect(args[0]);
// bot.joinChannel(args[1]);
// }
public static void main(String args[]) {
SpeechBot bot = new SpeechBot("SpeechBot");
bot.onMessage("a", "a", "a", "a", "C P U overload 77%");
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -