?? 80105d76ce85001c1c07b990949a4770
字號:
/*******************************************************************************
* Copyright (c) 2004 Berthold Daum. All rights reserved. This program and the
* accompanying materials are made available under the terms of the Common
* Public License v1.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors: Berthold Daum
******************************************************************************/
package com.bdaum.dukeSpeaks;
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.URL;
import java.util.Locale;
import javax.swing.*;
import com.sun.speech.freetts.Age;
import com.sun.speech.freetts.Gender;
import com.sun.speech.freetts.audio.AnimatedAudioPlayer;
import com.sun.speech.freetts.en.us.AnimatedDiphoneVoice;
import com.sun.speech.freetts.en.us.CMULexicon;
import com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory;
import com.sun.speech.freetts.relp.Animator;
/**
* @author Berthold Daum
*
* Creation date: 01.10.2003
*
*/
public class Player extends JFrame {
private PlayerPanel playerPanel;
/**
* @see java.awt.Frame#Frame(String)
*/
public Player(String title) {
super(title);
// Set Look&Feel for Swing
setDefaultLookAndFeelDecorated(true);
// WindowListener for close button event handling
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
// Create new Animator object
Animator a = new Animator();
// Get URL of the voice database
URL url = KevinVoiceDirectory.class.getResource("cmu_us_kal16.bin");
// Create Voice object - see com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory
AnimatedDiphoneVoice voice =
new AnimatedDiphoneVoice("kevin16", Gender.MALE,
Age.YOUNGER_ADULT, "default 16-bit diphone voice",
Locale.US, "general", "cmu", new CMULexicon(),
url, a);
// Use AnimatedAudioPlayer as audio player
// for this voice
voice.setAudioPlayer(new AnimatedAudioPlayer(a));
// Create Face object
Face face = new Face();
// Set face border area
face.setBorder(BorderFactory.createEmptyBorder(30, 30, 10, 30));
// Register Face object as
// AnimationListener with Animator object
a.addAnimationListener(face);
// Load the voice (mainly the lexicon)
voice.allocate();
// Create a PlayerModel instance with the new voice
PlayerModelImpl impl = new PlayerModelImpl(voice);
// Create a PlayerPanel instance and pass the PlayerModel object
// and the Face-Objekt to it.
playerPanel = new PlayerPanel(impl,face);
// Use the size of the PlayerPanel for the whole Player
setSize(playerPanel.getContentPane().getSize());
// Insert the PlayerPanel into the Player
getContentPane().add(playerPanel.getContentPane(), BorderLayout.CENTER);
}
/**
* Method main.
* The main() method of the Player.
*
* @param args (not used)
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// Set Metal Look&Feel for Swing
try {
UIManager.setLookAndFeel(
"javax.swing.plaf.metal.MetalLookAndFeel");
} catch(Exception e) {
System.err.println("Error setting look&feel: " + e);
}
// Create new Player instance
Player player = new Player("Animated FreeTTS Player");
// and display it
player.setVisible(true);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -