⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 40088a12d085001c1c07b990949a4770

📁 一个非常有意思,并且带图像的语音项目,能读出相应的英文,并有口型
💻
字号:
/*******************************************************************************
 * 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.AnimatedDisphoneVoice;;
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
		AnimatedDisphoneVoice voice = new AnimatedDisphoneVoice
		("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 + -