亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? emacspeakprotocolhandler.java

?? 使用Exlipse編寫的一個語音程序
?? 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 com.sun.speech.freetts.util.Utilities;import java.io.BufferedReader;import java.io.DataOutputStream;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStream;import java.net.Socket;import java.net.SocketTimeoutException;/** * Implements a very simplified (and incomplete) version of the * Emacspeak speech server. * * See the Emacspeak protocol document at * http://emacspeak.sourceforge.net/info/html/TTS-Servers.html * for more information. */public abstract class EmacspeakProtocolHandler implements Runnable {    // network related variables    private Socket socket;    private BufferedReader reader;    private OutputStream writer;    // synthesizer related variables    protected static final String PARENS_STAR_REGEX = "[.]*\\[\\*\\][.]*";    private static final int NOT_HANDLED_COMMAND = 1;    private static final int LETTER_COMMAND = 2;    private static final int QUEUE_COMMAND = 3;    private static final int TTS_SAY_COMMAND = 4;    private static final int STOP_COMMAND = 5;    private static final int EXIT_COMMAND = 6;    private static final int RATE_COMMAND = 7;        private String lastQueuedCommand;    private String stopQuestionStart = "Active processes exist;";    private boolean debug = false;    /**     * Sometimes emacspeak will embed DECTalk escape sequences in the     * text.  These sequences are not meant to be spoken, and FreeTTS     * currently does not interpret them.  This simple flag provides     * a mechanism for FreeTTS to cut strings of the form "[...]"     * out of text to be spoken (DECTalk escape sequences are of the     * form "[...]").  Since this is a relatively heavy-handed thing     * to do, this feature is turned off by default.  To turn it on,     * add -DstripDECTalk=true to the command line.     */    private boolean stripDECTalk = false;    /**     * Sets the Socket to be used by this ProtocolHandler.     *     * @param socket the Socket to be used     */    public void setSocket(Socket socket) {	this.socket = socket;	if (socket != null) {	    try {		reader = new BufferedReader		    (new InputStreamReader(socket.getInputStream()));		writer = new DataOutputStream(socket.getOutputStream());                socket.setKeepAlive(true);                // socket.setSoTimeout(5000);	    } catch (IOException ioe) {		ioe.printStackTrace();		throw new Error();	    }	}    }    /**     * Returns the socket used.     *     * @return the socket used     */    public Socket getSocket() {        return socket;    }    /**     * Set to debug mode, which will print out debug messages.     *     * @param true if set to debug mode, false if set to non-debug mode.     */    public void setDebug(boolean debug) {        this.debug = debug;    }    /**     * Returns true if the given input string starts with the given     * starting and ending sequence.     *     * @param start the starting character sequence     * @param end the ending character sequence     *      * @return true if the input string matches the given Pattern;     *         false otherwise     */    private static boolean matches(String start, String end, String input) {	return (input.startsWith(start) && input.endsWith(end));    }    /**     * Returns the type of the given command.     *     * @param command the command from emacspeak     *     * @return the command type     */    private static int getCommandType(String command) {	int type = NOT_HANDLED_COMMAND;        if (command.startsWith("l ")) {            type = LETTER_COMMAND;        } else if (command.startsWith("q ")) {            type = QUEUE_COMMAND;        } else if (command.startsWith("tts_say ")) {            type = TTS_SAY_COMMAND;        } else if (command.startsWith("tts_set_speech_rate ")) {            type = RATE_COMMAND;        } else if (command.equals("s")) {            type = STOP_COMMAND;        } else if (command.equals("exit")) {            type = EXIT_COMMAND;        }	return type;    }        /**     * Returns the text of the given input that is within curly     * brackets.  If there are no curly brackets (allowed in the     * Emacspeak protocol if the text has no spaces), then it     * just returns the text after the first space.     *     * @param input the input text     *     * @return text within curly brackets     */    public static String textInCurlyBrackets(String input) {	String result = "";	if (input.length() > 0) {	    int first = input.indexOf('{');            if (first == -1) {                first = input.indexOf(' ');            }	    int last = input.lastIndexOf('}');            if (last == -1) {                last = input.length();            }	    if (first != -1 && last != -1 &&		first < last) {		result = input.substring(first+1, last);	    }	}	return result.trim();    }    /**     * Strips DECTalk commands from the input text.  The DECTalk     * commands are anything inside "[" and "]".     */    public String stripDECTalkCommands(String content) {        int startPos = content.indexOf('[');        while (startPos != -1) {            int endPos = content.indexOf(']');            if (endPos != -1) {                if (startPos == 0) {                    if (endPos == (content.length() - 1)) {                        content = "";                    } else {                        content = content.substring(endPos + 1);                    }                } else {                    if (endPos == (content.length() - 1)) {                        content = content.substring(0, startPos);                    } else {                        String firstPart = content.substring(0, startPos);                        String secondPart = content.substring(endPos + 1);                        content = firstPart + " " + secondPart;                    }                }                startPos = content.indexOf('[');            } else {                break;            }        }        return content.trim();    }        /**     * Speaks the given input text.     *     * @param input the input text to speak.     */    public abstract void speak(String input);    /**     * Removes all the queued text.     */    public abstract void cancelAll();    /**     * Sets the speaking rate.     *     * @param wpm the new speaking rate (words per minute)     */    public abstract void setRate(float wpm);    /**     * Implements the run() method of Runnable     */    public synchronized void run() {        try {            String command = "";            stripDECTalk = Utilities.getBoolean("stripDECTalk");            while (isSocketLive()) {                command = reader.readLine();                if (command != null) {                    command = command.trim();                    debugPrintln("IN   : " + command);                    int commandType = getCommandType(command);                    if (commandType == EXIT_COMMAND) {                        socket.close();                        notifyAll();                    } else if (commandType == STOP_COMMAND) {                        cancelAll();                    } else if (commandType == RATE_COMMAND) {                        try {                            setRate(Float.parseFloat(                                        textInCurlyBrackets(command)));                        } catch (NumberFormatException e) {                            // ignore and do nothing                        }                    } else if (commandType != NOT_HANDLED_COMMAND) {                        String content = textInCurlyBrackets(command);                        if (stripDECTalk) {                            content = stripDECTalkCommands(content);                        }                        if (content.length() > 0) {                            speak(content);                        }                        // detect if emacspeak is trying to quit                        detectQuitting(commandType, content);                    } else {                        debugPrintln("SPEAK:");                    }                }            }        } catch (IOException ioe) {            ioe.printStackTrace();        } finally {            debugPrintln("EmacspeakProtocolHandler: thread terminated");        }    }    /**     * Returns true if the Socket is still alive.     *     * @return true if the Socket is still alive     */    private boolean isSocketLive() {        return (socket.isBound() &&                !socket.isClosed() && socket.isConnected() &&                !socket.isInputShutdown() && !socket.isOutputShutdown());    }    /**     * Read a line of text. A line is considered to be terminated      * by any one of a line feed ('\n'), a carriage return ('\r'),     * or a carriage return followed immediately by a linefeed.      *     * @return A String containing the contents of the line,      * not including any line-termination     * characters, or null if the end of the stream has been reached     *     * @throws IOException if an I/O error occurs     */    private String readLine() throws IOException {        String command = null;        boolean repeat = false;        do {            try {                command = reader.readLine();                repeat = false;            } catch (SocketTimeoutException ste) {                System.out.println("timed out");                /*                writer.write(-1);                writer.flush();                */                repeat = isSocketLive();            }        } while (repeat);             return command;    }        /**     * Detects and handles a possible emacspeak quitting sequence      * of commands, by looking at the given command type and content.     * If a quitting sequence is detected, it will close the socket.     * Note that this is not the best way to trap a quitting sequence,     * but I can't find another way to trap it. This method will     * do a socket.notifyAll() to tell objects waiting on the socket     * that it has been closed.      *     * @param commandType the command type     * @param content the contents of the command     */    private synchronized void detectQuitting(int commandType, String content)        throws IOException {        if (commandType == QUEUE_COMMAND) {            lastQueuedCommand = content;        } else if (commandType == TTS_SAY_COMMAND) {            if (content.equals("no")) {                lastQueuedCommand = "";            } else if (content.equals("yes") &&                       lastQueuedCommand.startsWith(stopQuestionStart)) {                socket.close();                notifyAll();            }        }    }    /**     * Prints the given message if the <code>debug</code> System property     * is set to <code>true</code>.     *     * @param message the message to print     */     public void debugPrintln(String message) {	if (debug) {	    System.out.println(message);	}    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美伦理电影网| 日韩在线卡一卡二| 欧美日韩一卡二卡三卡| av一区二区不卡| 99久久久国产精品| 91免费精品国自产拍在线不卡| 99热在这里有精品免费| 欧美一级午夜免费电影| 欧美日本在线视频| 精品日韩一区二区三区| 欧美韩日一区二区三区| 久久免费视频色| 日本一区二区三区高清不卡| 国产精品久久久久久一区二区三区| 国产精品国产三级国产普通话蜜臀 | 日韩专区一卡二卡| 99久久免费视频.com| 国产日本亚洲高清| 久久国产麻豆精品| eeuss鲁一区二区三区| 26uuu久久综合| 日韩毛片视频在线看| 天堂av在线一区| 91福利国产成人精品照片| 日韩一区二区三区电影在线观看 | 欧美性受xxxx| 久久免费午夜影院| 麻豆久久一区二区| 91丨porny丨首页| 中文字幕第一页久久| 国产精品一区在线| 欧美精品视频www在线观看| 亚洲欧美国产三级| 黄一区二区三区| 欧美亚洲综合久久| 亚洲二区在线观看| 懂色av中文字幕一区二区三区| 在线观看成人免费视频| 久久色视频免费观看| 国产在线精品一区二区| 欧美在线视频全部完| 一区二区三区免费看视频| 国产真实乱偷精品视频免| www国产精品av| 国内精品视频666| 久久久久国产一区二区三区四区| 国产乱子伦一区二区三区国色天香| 欧美不卡一区二区三区四区| 国内精品国产成人| 国产日韩成人精品| 99久久99久久免费精品蜜臀| 亚洲人成人一区二区在线观看 | 精品精品国产高清一毛片一天堂| 一区二区三区不卡在线观看| 欧美亚洲动漫精品| 免费欧美日韩国产三级电影| 欧美在线免费观看视频| 亚洲国产毛片aaaaa无费看| 欧美日本一区二区三区四区| 极品少妇xxxx精品少妇| 日韩欧美成人午夜| 蜜臀av亚洲一区中文字幕| 26uuu欧美| 99国产精品国产精品毛片| 丝袜亚洲另类欧美综合| 26uuu国产日韩综合| 99久久精品免费| 首页国产欧美日韩丝袜| 日本一区二区在线不卡| 色婷婷精品大视频在线蜜桃视频| 最近中文字幕一区二区三区| 欧美日韩国产天堂| 国产一区二区美女诱惑| 亚洲激情男女视频| 色欧美88888久久久久久影院| 婷婷丁香久久五月婷婷| 777亚洲妇女| 日韩av不卡一区二区| 欧美一区二区黄色| 99久久国产综合精品色伊| 免费精品99久久国产综合精品| 国产精品久久久久久亚洲毛片| 欧美精品久久久久久久多人混战 | 国产精品电影一区二区| 欧美日韩久久一区| 成人午夜看片网址| 中文字幕中文字幕一区二区| 欧美一区二区三区的| 91理论电影在线观看| 国产一区视频网站| 亚洲mv在线观看| 精品国产凹凸成av人导航| 在线观看欧美日本| www.激情成人| 国产一区二区三区观看| 麻豆视频一区二区| 午夜av区久久| 亚洲码国产岛国毛片在线| 久久婷婷一区二区三区| 91精品免费观看| 欧洲av一区二区嗯嗯嗯啊| 成人h动漫精品一区二区| 亚洲午夜精品17c| 一区二区三区免费在线观看| 日韩毛片高清在线播放| 国产精品国产精品国产专区不片| 久久女同性恋中文字幕| 精品久久久影院| 91精品国产综合久久久久久漫画| 精品视频全国免费看| 色狠狠色噜噜噜综合网| 一本色道久久综合亚洲精品按摩| 成人综合激情网| 成人综合婷婷国产精品久久蜜臀| 国产东北露脸精品视频| 亚洲成人午夜电影| 亚洲一区二区三区激情| 久久久国际精品| 久久久久久毛片| 国产午夜精品美女毛片视频| 欧美日韩国产综合视频在线观看| 色婷婷国产精品| 欧美日韩精品一区二区三区| 欧美吞精做爰啪啪高潮| 欧美卡1卡2卡| 日韩欧美一级在线播放| 精品播放一区二区| 久久精品日韩一区二区三区| 国产欧美日本一区视频| 中文字幕亚洲一区二区va在线| 欧美变态口味重另类| 337p日本欧洲亚洲大胆色噜噜| 国产亚洲精品久| 中文字幕一区av| 午夜久久久久久电影| 麻豆91小视频| 成人福利视频网站| 在线一区二区三区| 欧美一区二区三区视频在线| 久久精品一区二区三区av| 亚洲欧洲日韩女同| 亚洲va欧美va天堂v国产综合| 蜜臀a∨国产成人精品| 高潮精品一区videoshd| 色菇凉天天综合网| 日韩欧美国产综合| 国产精品蜜臀av| 中文字幕成人av| 亚洲成人av福利| 国产99久久久久久免费看农村| 色婷婷综合久久久中文一区二区| 91精品婷婷国产综合久久性色| 国产色产综合色产在线视频| 亚洲免费三区一区二区| 久久99久久久欧美国产| 不卡欧美aaaaa| 67194成人在线观看| 欧美高清在线视频| 日韩中文字幕一区二区三区| 国产.欧美.日韩| 日韩一区二区三区三四区视频在线观看 | 3751色影院一区二区三区| 国产精品每日更新| 另类调教123区 | 国产精品全国免费观看高清 | 国产99精品国产| 欧美美女喷水视频| 国产精品免费网站在线观看| 日韩精品久久理论片| 99re热这里只有精品视频| 日韩久久免费av| 午夜国产精品一区| 91女人视频在线观看| 久久久久久久av麻豆果冻| 午夜精品福利一区二区三区蜜桃| 成人久久久精品乱码一区二区三区| 717成人午夜免费福利电影| 亚洲欧美一区二区视频| 韩国女主播一区二区三区| 欧美日韩国产小视频在线观看| 中文字幕日韩一区| 国产最新精品精品你懂的| 91精品蜜臀在线一区尤物| 亚洲影院在线观看| 91免费看片在线观看| 中文字幕高清一区| 国产成人午夜精品5599| 欧美色图激情小说| 一级特黄大欧美久久久| 不卡大黄网站免费看| 国产午夜精品久久久久久久 | 日本中文字幕不卡| 欧美亚洲一区二区在线观看| 亚洲免费av在线| 色综合久久久久网| 亚洲人xxxx| 色婷婷香蕉在线一区二区| 成人免费一区二区三区视频 | 欧美日韩mp4| 亚洲永久精品大片|