?? jsapiemacspeakhandler.java
字號:
/** * Copyright 2001 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL * WARRANTIES. */import java.net.Socket;import javax.speech.synthesis.Synthesizer;import com.sun.speech.freetts.util.Utilities;/** * Implements a very simplified version of the Emacspeak speech server. */public class JSAPIEmacspeakHandler extends EmacspeakProtocolHandler { // synthesizer related variables private Synthesizer synthesizer; /** * Constructs a JSAPIEmacspeakHandler. * * @param socket the Socket that holds the TCP connection * @param synthesizer the JSAPI synthesizer to use */ public JSAPIEmacspeakHandler(Socket socket, Synthesizer synthesizer) { setSocket(socket); this.synthesizer = synthesizer; setDebug(Utilities.getBoolean("debug")); } /** * Speaks the given input text. * * @param input the input text to speak. */ public void speak(String input) { // split around "[*]" String[] parts = input.split(PARENS_STAR_REGEX); for (int i = 0; i < parts.length; i++) { debugPrintln(parts[i]); synthesizer.speakPlainText(parts[i], null); } } /** * Removes all the queued text. */ public void cancelAll() { synthesizer.cancelAll(); } /** * Sets the speaking rate. * * @param wpm the new speaking rate (words per minute) */ public void setRate(float wpm) { try { synthesizer.getSynthesizerProperties().setSpeakingRate(wpm); } catch (java.beans.PropertyVetoException e) { // ignore and do nothing } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -