Freetts realizes speech synthesis-----converts IRC messages into audible speech

Source: Internet
Author: User

This article will show you how to build a cross-platform IRC robot (an automated client) that uses the Freetts Java Speech Synthesis Library to convert IRC messages into audible speech. The Freetts library can be downloaded at freetts.sourceforge.net.  To connect to an IRC server, you need to download the Pircbot Java IRC API in www.jibble.org/pircbot.php. Once you have downloaded the two libraries you need, create a Lib directory, and then copy the following. jar files to the inside. Cmu_time_awb.jar

Cmu_us_kal.jar

Cmulex.jar

Cmutimelex.jar

En_us.jar

Freetts.jar

Pircbot.jar Now, writing IRC robots has become a simple task, because these libraries will do most of the difficult work for you. Create a file named Speechbot.java:

Import org.jibble.pircbot.*;

Import com.sun.speech.freetts.*;

Import com.sun.speech.freetts.audio.*;

Import javax.sound.sampled.*;

Import Java.io.File;

public class Speechbot {

Private Voice Voice;

Public Speechbot (String say) {

SetName (name); Choose The voice for the speech synthesizer.

Select the voice of the speech synthesizer

String voicename = "Kevin16";

Voicemanager Voicemanager = Voicemanager.getinstance ();

Voice = Voicemanager.getvoice (Voicename);

if (voice = = null) {

System.out.println ("Voice not Found.");

System.exit (1);

}

Voice.allocate (); Set up the output format. Allocating resources
Set output format
Audioplayer Voiceplayer = new Javaclipaudioplayer ();

Voiceplayer.setaudioformat (New Audioformat (8000, 1, false, true));

Voice.setaudioplayer (Voiceplayer);


float WPM = 120f;//set speed
Voice.setrate (WPM);
Voice.setpitch (85f);
Voice.setpitchrange (10f);
Synthetic speech
Voice.startbatch ();
Voice.speak (say);
Voice.endbatch ();


You can get a synthetic voice file here


Releasing resources
Voice.deallocate ();
}

public void OnMessage (string channel, String sender,

string login, string hostname, string message {

Send all IRC messages to the voice

Synthesizer.

Send all IRC messages to speech synthesizer

message = Message.trim ();

String input = sender + "On" + Channel + "

Says: "+ message;

Voice.speak (input);

}

public static void Main (string[] args) throws Exception {


Speechbot bot = new Speechbot ("Speechbot");
 
}}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.