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

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

?? playermodelimpl.java

?? 使用Exlipse編寫的一個語音程序
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/** * 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.beans.PropertyVetoException;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.InputStream;import java.io.InputStreamReader;import java.io.IOException;import java.net.MalformedURLException;import java.net.URL;import java.util.Enumeration;import java.util.Locale;import java.util.HashSet;import java.util.Set;import java.util.Iterator;import javax.speech.AudioException;import javax.speech.Central;import javax.speech.Engine;import javax.speech.EngineException;import javax.speech.EngineList;import javax.speech.synthesis.Synthesizer;import javax.speech.synthesis.SynthesizerModeDesc;import javax.speech.synthesis.SynthesizerProperties;import javax.speech.synthesis.Voice;import javax.swing.DefaultComboBoxModel;import javax.swing.DefaultListModel;import javax.swing.JFrame;import javax.swing.ListModel;import com.sun.speech.engine.synthesis.SynthesizerMonitor;/** * Implements the text-to-speech data model of the Player application, using * JSAPI. It should work with any JSAPI implementation. */public class PlayerModelImpl implements PlayerModel {    private Synthesizer synthesizer;    private Monitor monitor;    private boolean monitorVisible = false;    private boolean paused = false;    private boolean stopped = false;    private boolean playingFile = false;    private DefaultListModel playList;    private DefaultComboBoxModel synthesizerList;    private DefaultComboBoxModel voiceList;    private float volume = -1;    private static boolean debug = false;    private Set loadedSynthesizers;        /**     * Constructs a default PlayerModelImpl.     */    public PlayerModelImpl() {	playList = new DefaultListModel();	synthesizerList = new DefaultComboBoxModel();	voiceList = new DefaultComboBoxModel();	loadedSynthesizers = new HashSet();    }        /**     * Creates a FreeTTS synthesizer.     */    public void createSynthesizers() {	try {	    EngineList list = Central.availableSynthesizers(null); 	    Enumeration e = list.elements();	    while (e.hasMoreElements()) {		MySynthesizerModeDesc myModeDesc =		    new MySynthesizerModeDesc		    ((SynthesizerModeDesc) e.nextElement(), this);		debugPrint(myModeDesc.getEngineName() + " " +			   myModeDesc.getLocale() + " " +			   myModeDesc.getModeName() + " " +			   myModeDesc.getRunning());		synthesizerList.addElement(myModeDesc);	    }	    	    if (synthesizerList.getSize() > 0) {		setSynthesizer(0);	    } else {		System.err.println(noSynthesizerMessage());	    }            if (synthesizer == null) {                System.err.println("PlayerModelImpl: Can't find synthesizer");                System.exit(1);            }        } catch (Exception e) {            e.printStackTrace();        }    }    /**     * Returns a "no synthesizer" message, and asks      * the user to check if the "speech.properties" file is     * at <code>user.home</code> or <code>java.home/lib</code>.     *     * @return a no synthesizer message     */    static private String noSynthesizerMessage() {        String message =            "No synthesizer created.  This may be the result of any\n" +            "number of problems.  It's typically due to a missing\n" +            "\"speech.properties\" file that should be at either of\n" +            "these locations: \n\n";        message += "user.home    : " + System.getProperty("user.home") + "\n";        message += "java.home/lib: " + System.getProperty("java.home") +	    File.separator + "lib\n\n" +            "Another cause of this problem might be corrupt or missing\n" +            "voice jar files in the freetts lib directory.  This problem\n" +            "also sometimes arises when the freetts.jar file is corrupt\n" +            "or missing.  Sorry about that.  Please check for these\n" +            "various conditions and then try again.\n";        return message;    }	        /**     * Performs TTS on the given Playable.     *     * @param playable the Playable object to play     */    public void play(Playable playable) {	if (playable != null) {	    if (playable.getType() == PlayableType.TEXT) {		play(playable.getText());	    } else if (playable.getType() == PlayableType.JSML) {		playJSML(playable.getText());	    } else if (playable.getType() == PlayableType.TEXT_FILE ||		       playable.getType() == PlayableType.JSML_FILE) {		playFile(playable.getFile(), playable.getType());	    } else if (playable.getType() == PlayableType.URL) {		try {		    playURL(new URL(playable.getName()));		} catch (MalformedURLException mue) {		    mue.printStackTrace();		}	    }	}    }    /**     * Performs TTS on the object at the given index of the play list.     *     * @param index index of the object in the playlist to play     */    public void play(int index) {	if (0 <= index && index < playList.getSize()) {	    Playable playable = (Playable) playList.getElementAt(index);	    if (playable != null) {		play(playable);	    }	}    }    /**     * Performs text-to-speech on the given text.     *     * @param text the text to perform TTS     */    private void play(String text) {	synthesizer.speakPlainText(text, null);    }        /**     * Performs text-to-speech on the given JSML text.     *     * @param text the text to perform TTS     */    private void playJSML(String jsmlText) {	try {	    synthesizer.speak(jsmlText, null);	} catch (Exception e) {	    e.printStackTrace();	}    }    /**     * Plays the text in the given File.     *     * @param file the File to play     * @param type the file type     */    private void playFile(File file, PlayableType type) {	try {	    FileInputStream fileStream = new FileInputStream(file);	    playInputStream(fileStream, type);	} catch (FileNotFoundException fnfe) {	    fnfe.printStackTrace();	}    }	    /**     * Plays the text in the given File.     *     * @param file the File to play     * @param type the file type     */    private void playInputStream(InputStream inStream, PlayableType type) {	playingFile = true;	if (inStream != null) {	    try {		BufferedReader reader = new BufferedReader		    (new InputStreamReader(inStream));		String line = "";		if (type == PlayableType.TEXT_FILE) {		    while (!isStopped() && 			   (line = reader.readLine()) != null) {			if (line.length() > 0) {			    play(line);			}		    }		} else if (type == PlayableType.JSML_FILE) {		    String fileText = "";		    while ((line = reader.readLine()) != null) {			fileText += line;		    }		    if (fileText != null && fileText.length() > 0) {			playJSML(fileText);		    }		}		stopped = false;	    } catch (IOException ioe) {		ioe.printStackTrace();	    }	}	playingFile = false;    }    /**     * Plays the contents of the given URL.     *     * @param url the URL to play     */    private void playURL(URL url) {	try {	    synthesizer.speak(url, null);	} catch (Exception e) {	    e.printStackTrace();	}    }	    /**     * Returns true if the player is paused.     *     * @return true if the player is paused, false otherwise     */    public synchronized boolean isPaused() {	return paused;    }        /**     * Pauses the player.     */    public synchronized void pause() {	paused = true;	synthesizer.pause();    }            /**     * Resumes the player.     */    public synchronized void resume() {	paused = false;	try {	    synthesizer.resume();	} catch (AudioException ae) {	    ae.printStackTrace();	}	    }                /**     * Stops the player if it is playing.     */    public synchronized void stop() {	if (playingFile) {	    stopped = true;	}	synthesizer.cancelAll();    }    /**     * Cancels the currently playing item.     */    public void cancel() {	synthesizer.cancel();    }    /**     * Close this playable     */    public void close() {	for (Iterator i = loadedSynthesizers.iterator(); i.hasNext();) {	    Synthesizer synth = (Synthesizer) i.next();	    try {		synth.deallocate();	    } catch (EngineException ee) {		System.out.println("Trouble closing the synthesizer: " + ee);	    }	}    }    /**     * Returns true if the Player is currently being stopped.     *     * @return true if the Player is currently being stopped; false otherwise     */        private synchronized boolean isStopped() {	return stopped;    }        /**     * Sets whether the Monitor is visible     *     * @param visible true to set the Monitor as visible     */    public void setMonitorVisible(boolean visible) {	monitorVisible = visible;	if (monitor != null) {	    monitor.setVisible(monitorVisible);	}    }        /**     * Tells whether the monitor is visible.     *     * @return true if the monitor is visible, false otherwise     */    public boolean isMonitorVisible() {	return monitorVisible;    }                /**     * Returns the monitor of the synthesizer at the given index.     *     * @param index the position of the synthesizer in the synthesizer list     *     * @return the monitor of the specified synthesizer     */    public Monitor getMonitor(int index) {	MySynthesizerModeDesc myModeDesc = (MySynthesizerModeDesc)	    synthesizerList.getElementAt(index);	Monitor monitor = null;	if (myModeDesc != null) {	    monitor = myModeDesc.getMonitor();	}	return monitor;    }    /**     * Returns the monitor of the current synthesizer.     *     * @return the monitor of the current synthesizer     */    public Monitor getMonitor() {	return monitor;    }    /**     * Sets the current monitor.     *     * @param monitor the current monitor     */    public void setMonitor(Monitor monitor) {	this.monitor = monitor;    }    /**     * Sets the Synthesizer at the given index to use     *     * @param index index of the synthesizer in the list     */    public void setSynthesizer(int index) {	MySynthesizerModeDesc myModeDesc = (MySynthesizerModeDesc)	    synthesizerList.getElementAt(index);	if (myModeDesc != null) {	    if (isMonitorVisible()) {		if (monitor != null) {		    monitor.setVisible(false);		}	    }	    synthesizer = myModeDesc.getSynthesizer();	    if (synthesizer == null) {		synthesizer = myModeDesc.createSynthesizer();		if (synthesizer == null) {		    debugPrint("still null");		} else {		    debugPrint("created");		}	    } else {		debugPrint("not null");	    }	    monitor = myModeDesc.getMonitor();	    if (myModeDesc.isSynthesizerLoaded()) {		setVoiceList(myModeDesc);	    } else {		myModeDesc.loadSynthesizer();	    }	    loadedSynthesizers.add(synthesizer);            synthesizerList.setSelectedItem(myModeDesc);	}    }        /**     * Sets the Voice at the given to use.     *     * @param index the index of the voice     */    public void setVoice(int index) {	try {	    Voice voice = (Voice) voiceList.getElementAt(index);	    if (voice != null) {		float oldVolume = getVolume();		float oldSpeakingRate = getSpeakingRate();		synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);		synthesizer.getSynthesizerProperties().setVoice(voice);		setVolume(oldVolume);		setSpeakingRate(oldSpeakingRate);                voiceList.setSelectedItem(voice);	    }	} catch (PropertyVetoException pve) {	    pve.printStackTrace();	} catch (InterruptedException ie) {	    ie.printStackTrace();	}    }        /**     * Returns the volume, in the range of 0 to 10.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
9191成人精品久久| 国产免费成人在线视频| 国产欧美综合在线| 日韩精品福利网| 成人美女视频在线观看| 欧美久久久久久蜜桃| 国产精品久久午夜夜伦鲁鲁| 青青草原综合久久大伊人精品优势| www.欧美色图| 久久久久久久综合日本| 日韩国产精品大片| 在线一区二区观看| 综合久久给合久久狠狠狠97色 | 国产精品水嫩水嫩| 免费欧美在线视频| 欧美日韩极品在线观看一区| 亚洲欧美日韩成人高清在线一区| 国产精品羞羞答答xxdd| 精品久久一区二区| 奇米精品一区二区三区四区 | 日韩专区一卡二卡| 欧美在线免费视屏| 亚洲午夜一区二区三区| 色一区在线观看| 亚洲精品国产a| 一本色道久久加勒比精品| 18欧美乱大交hd1984| www.亚洲人| 亚洲视频你懂的| 91丨九色丨尤物| 亚洲猫色日本管| 欧美性生活久久| 日韩精品一二区| 欧美成人vr18sexvr| 国内精品久久久久影院薰衣草| 欧美mv和日韩mv国产网站| 久久精品二区亚洲w码| www国产成人| 丁香婷婷综合五月| 中文字幕亚洲视频| 欧美午夜精品一区二区蜜桃 | 成人性生交大合| 国产精品嫩草影院com| 成人av午夜影院| 一区二区三区视频在线观看| 在线精品视频一区二区三四| 三级影片在线观看欧美日韩一区二区 | 国产激情视频一区二区三区欧美| 国产欧美一区二区精品忘忧草| 风间由美一区二区三区在线观看 | 一本大道av伊人久久综合| 亚洲电影第三页| 欧美成人激情免费网| 从欧美一区二区三区| 一级女性全黄久久生活片免费| 欧美日韩精品一区二区三区| 美美哒免费高清在线观看视频一区二区 | 国产麻豆视频一区二区| 中文字幕视频一区二区三区久| 欧美色老头old∨ideo| 奇米四色…亚洲| 中文字幕一区二区三中文字幕| 欧美巨大另类极品videosbest| 九色porny丨国产精品| 国产精品免费视频网站| 欧美日韩高清不卡| 不卡的看片网站| 蜜桃久久精品一区二区| 亚洲日本一区二区| 欧美不卡在线视频| 在线免费亚洲电影| 国产高清视频一区| 天天色 色综合| 国产精品成人免费在线| 日韩欧美在线影院| 色偷偷88欧美精品久久久| 国产自产高清不卡| 亚洲第一激情av| 国产精品久久久久久亚洲伦| 欧美一区二区三区思思人| 97se亚洲国产综合自在线| 久久99国内精品| 亚洲成人福利片| 亚洲日本乱码在线观看| 国产午夜亚洲精品羞羞网站| 欧美日韩一级片网站| 97精品国产97久久久久久久久久久久| 美女一区二区视频| 亚洲成人av一区二区三区| 国产精品久久久久久久午夜片| 日韩欧美一二区| 欧美日韩视频在线第一区| 99久久免费国产| 国产精品一级二级三级| 蜜臀av性久久久久蜜臀aⅴ四虎| 亚洲美女免费在线| 亚洲日本电影在线| 一区免费观看视频| 国产精品嫩草影院av蜜臀| 国产喂奶挤奶一区二区三区| 日韩一区二区免费在线电影| 欧美日韩精品欧美日韩精品| 在线日韩av片| 日本韩国一区二区三区视频| 91丨九色丨黑人外教| av动漫一区二区| 91天堂素人约啪| 91高清在线观看| 在线一区二区三区四区| 欧美三级日韩在线| 欧美无人高清视频在线观看| 欧美丝袜自拍制服另类| 欧美性xxxxxxxx| 欧美三级电影在线看| 欧美日韩成人综合天天影院 | 91女人视频在线观看| bt7086福利一区国产| 99视频一区二区三区| 99久久精品国产网站| 日本福利一区二区| 欧美亚洲动漫精品| 欧美巨大另类极品videosbest | 国产午夜三级一区二区三| wwwwww.欧美系列| 久久久亚洲欧洲日产国码αv| 久久久久久麻豆| 国产精品的网站| 亚洲影院免费观看| 美女性感视频久久| 国产成人av福利| 色综合av在线| 91精品综合久久久久久| 久久综合九色综合久久久精品综合| 国产欧美一区二区三区沐欲| 成人免费在线观看入口| 午夜国产不卡在线观看视频| 毛片av中文字幕一区二区| 国产麻豆91精品| 91香蕉视频污| 精品毛片乱码1区2区3区| 国产精品天干天干在线综合| 亚洲自拍偷拍av| 国产九色精品成人porny| 日本道在线观看一区二区| 欧美一区二区三区视频免费播放| 国产日韩欧美a| 亚洲高清免费一级二级三级| 九色综合国产一区二区三区| 色哟哟国产精品| 精品国产精品一区二区夜夜嗨| 亚洲国产精品99久久久久久久久| 亚洲丶国产丶欧美一区二区三区| 国产在线精品不卡| 91高清视频在线| 国产亚洲欧美一级| 视频在线观看一区二区三区| 国产精品一区二区三区99| 精品视频一区二区不卡| 欧美激情综合在线| 免费成人在线播放| 91极品视觉盛宴| 国产精品三级电影| 蜜桃视频免费观看一区| 在线亚洲免费视频| 日本一区二区久久| 久热成人在线视频| 欧美精品777| 亚洲狼人国产精品| 成人在线综合网| 欧美sm美女调教| 三级影片在线观看欧美日韩一区二区| 成人av电影在线播放| 久久嫩草精品久久久精品| 肉肉av福利一精品导航| 91成人免费电影| 亚洲日本电影在线| av在线不卡电影| 国产日产欧美一区二区视频| 久久精品国产成人一区二区三区| 欧美性感一类影片在线播放| 国产精品白丝在线| 成人精品亚洲人成在线| 久久九九久久九九| 国产一区二区三区免费| 日韩美女一区二区三区| 日韩成人一区二区三区在线观看| 色香蕉成人二区免费| 亚洲视频图片小说| 色综合久久久网| ●精品国产综合乱码久久久久| 高清久久久久久| 欧美国产97人人爽人人喊| 成人免费毛片片v| 中日韩av电影| 成人毛片在线观看| 亚洲天堂2016| 色成年激情久久综合| 亚洲一区二区免费视频| 欧美放荡的少妇| 蜜桃视频第一区免费观看|