Archive for December, 2007

The Animated Face The face with the lip

Monday, December 3rd, 2007

The Animated Face The face with the lip synchronization is implemented as a subclass of the Swing JPanel class. This class has the name Face and is created in the com.bdaum.dukeSpeaks package. The class implements the AnimationListener interface, which was created in the Animation Events section. This allows you to register the face as AnimationListener with an Animator instance. It will receive AnimationEvents from the Animator and can then react accordingly to these events. The Face.java class package com.bdaum.dukeSpeaks; import java.awt.*; import javax.swing.JPanel; import com.sun.speech.freetts.relp.AnimationEvent; import com.sun.speech.freetts.relp.AnimationListener; public class Face extends JPanel implements AnimationListener { // Relative mouth dimensions, derived from current phoneme float mouthWidth = 0.80f; float mouthHeight = 0.05f; // Relative eye pupil position, derived from current phoneme float eyePos = 0.16f; The processAnimationEvent() method receives animation events (AnimationEvent). From the transmitted phoneme it computes the size and shape of the mouth and the position of the eye pupils. The mouth is always drawn as an ellipsoid but with varying positions and diameters. After these values are computed, the repaint() method is called. This enforces the redrawing of the Face component. /** * @see com.sun.speech.freetts.relp.AnimationListener * #processAnimationEvent(AnimationEvent) */ public void processAnimationEvent(AnimationEvent e) { // Set current phoneme String phone = e.phone; if (phone.equals(”pau”)) { // In pauses pupils must look upwards eyePos = 0.15f; // In pauses mouth remains closed mouthWidth = 0.80f; mouthHeight = 0.05f; } else { // Otherwise pupils look downwards eyePos = 0.4f; // Analyze first character of phoneme char p1 = phone.charAt(0); switch (p1) { // Uh’s and Oh’s case ‘o’ : 85 Project One: Duke Speaks
Are you a Mac user in a search of Mac web hosting provider? We are. once upon a time, we were just like you, trying to find somebody who knows. Unfortunately, we had no luck, so we decided to help many others like you, and us. our team developed Mac friendly web hosting plans, feature packed, constantly monitored, and more than affordable. With us, you are home. Sign up.

Bulletproof web design - replace it with with the contents of the

Sunday, December 2nd, 2007

replace it with with the contents of the clipboard (Ctrl+V). Now, you can start modifying this class for your requirements. (Modifications are printed in bold type.) First, create a new private field: private LineListener externalLineListener; In the constructor, insert an equally named parameter and initialize the externalLineListener field with the parameter value: /** * Constructs a default AnimatedAudioPlayer */ public AnimatedAudioPlayer(LineListener externalLineListener) { this.externalLineListener = externalLineListener; debug = Boolean.getBoolean (”com.sun.speech.freetts.audio.AudioPlayer.debug”); closeDelay = Long.getLong (”com.sun.speech.freetts.audio.AudioPlayer.closeDelay”, 150L).longValue(); setPaused(false); } Then register externalLineListener in the end() method with the Clip object: … DataLine.Info info = new DataLine.Info(Clip.class, currentFormat); Clip clip = (Clip) AudioSystem.getLine(info); clip.addLineListener(lineListener); clip.addLineListener(externalLineListener); clip.open(currentFormat, outputData, 0, outputData.length); setVolume(clip, volume); … Finally, apply the Source > Organize Imports function to remove all unnecessary import statements. The User Interface The user interface is implemented with Swing. Since no Eclipse components are used at all, you can easily execute this application outside of Eclipse. The other reason for using Swing is that I want to demonstrate the Eclipse Visual Editor (VE), which in its current version (0.5) supports only Swing. Because the code contains only standard Java programming, there is little to learn about Eclipse APIs in this section. Therefore, I will not discuss the code in detail but provide only a short overview. 84 Chapter 5
Don’t want to have just any web hosting, but web hosting provider who will share the same beliefs? You have found them. Our Church Web Hosting company will treat in you in appropriate way, the one you are accustomed to.

* @param age - the age of the (Php5 web hosting)

Saturday, December 1st, 2007

* @param age - the age of the voice * @param description - a human-readable string providing a * description that can be displayed to users. * @param locale - the locale of the voice * @param domain - the voice domain, e.g. general, time, wheather * @param organization the organization which created the voice * @param lexicon - the lexicon to load * @param database - a url to the unit database file for this voice * @param animator - the animator for lip synchronization */ public AnimatedDiphoneVoice(String name,Gender gender,Age age, String description, Locale locale, String domain, String organization, CMULexicon lexicon, URL database, UtteranceProcessor animator) { super(name, gender, age, description, locale, domain, organization, lexicon, database); this.animator = animator; } /** * @see com.sun.speech.freetts.Voice#getAudioOutput() */ protected UtteranceProcessor getAudioOutput() throws IOException { return new AnimatedAudioOutput(animator); } } Listing 5.4 (Continued) Because you want this class to create an AnimatedAudioOutput, you must override the getAudioOutput() method. Here, too, you can make use of the Source > Override Methods context function. In the dialog that appears, mark the getAudioOutput() method below the CMUVoice class. Then, just complete the method as shown above. Connection with the Java Audio System What is still missing is the program logic for starting the animator. Here, you must first register the Animator as LineListener with a javax.sound.sampled.Line object. Such an object is created by the com.sun.speech.freetts.audio.JavaClipAudioPlayer player in the end() method in the disguise of a javax.sound.sampled.Clip object. The correct way to extend JavaClipAudioPlayer would be to subclass it. But unfortunately JavaClipAudioPlayer proves to be a stubborn beast. Too many private fields prevent us from applying the required extensions. Therefore, choose a different path. Simply create a copy of JavaClipAudioPlayer, which you then can modify easily. Theoretically, you could use the Copy function of the Package Explorer, but unfortunately this function cannot be applied to the contents of external JARs. Therefore, you must first create the new com.sun.speech.freetts.audio package in the DukeSpeaks project and create in this package the new AnimatedAudioPlayer class. Then open the JavaClipAudioPlayer class in the FreeTTS package, select the whole text (Ctrl+A), and copy it (Ctrl+C) to the clipboard. Then select the whole text in the new AnimatedAudioPlayer class and 83 Project One: Duke Speaks
We are the the largest streaming host company, and we provide professional audio & video web hosting streaming using Real Networks, QuickTime, Flash and Windows Media.We strongly recommend you to visit and check web hosting streaming services.