-->
Home -> Java -> Come utilizzare MBROLA con FreeTTS in Java

Come utilizzare MBROLA con FreeTTS in Java

5
Jun
2010
0

In generale il riconoscimento vocale puo essere logicamente suddiviso in due aspetti: Sintesi e Riconoscimento.
L` implementazione di un servizio TTS (Test To Speech) in Java puo essere realizzata utilizzando le JSAPI realizzate dalla Sun di cui ne esiste una implemntazione free denominata FreeTTS.
FreeTTS offre solo i servizi di Sintesi, ignorando completamente l` aspetto legato al riconoscimento vocale.

In fase di sintesi, FreeTTS offre un set di voci decisamente metalliche e poco gradevoli tra cui quella di default e` denominata kevin16. L` idea e` di dotare il nostro software dell` utilizzo anche di un set di voci piu` “umane” importate dalle librerie MBROLA.

Sebbene non tutte siano supportate da FreeTTS ecco di seguito il codice Java necessario allo scopo:

The jars are available in the FreeTTS download page in the FreeTTs Bin Zip File at

http://sourceforge.net/project/showfiles.php?group_id=42080&package_id=34183&release_id=311626

System Classpath + User Classpath

C:\Program Files\Java\jdk1.5.0_06\lib\jsapi.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\cmulex.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\mbrola.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\freetts.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\en_us.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\cmutimelex.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\cmudict04.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\cmu_time_awb.jar;
C:\Program Files\Java\jdk1.5.0_06\lib\cmu_us_kal.jar;

User Path

C:\Program Files\Java\jdk1.5.0_06\lib
/**
* Copyright 2003 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 com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
import com.sun.speech.freetts.audio.JavaClipAudioPlayer;
/**
* Simple program to demonstrate the use of the FreeTTS speech
* synthesizer. This simple program shows how to use FreeTTS
* without requiring the Java Speech API (JSAPI).
*/
public class FreeTTS
{
VoiceManager voiceManager;
Voice voice;
public FreeTTS() {
}

public void TTS(String words)
{
String voiceName = "mbrola_us3";
//String voiceName = "kevin16";
// System.out.println();
//System.out.println("Using voice: " + voiceName);
// The VoiceManager manages all the voices for FreeTTS.
voiceManager = VoiceManager.getInstance();
voice = voiceManager.getVoice(voiceName);
/* Voice[] voices = voiceManager.getVoices();
for (int i = 0; i < voices.length; i++) {
System.out.println("" + voices[i].getName()+ " (" + voices[i].getDomain() + " domain)");
}*/

if (helloVoice == null)
{
System.err.println("Cannot find a voice named " + voiceName + ". Please specify a different voice.");
System.exit(1);
}

// Allocates the resources for the voice.
voice.allocate();

//Synthesize speech.
voice.speak(words);

// Clean up and leave.
voice.deallocate();
// System.exit(0);
}
}
Condividi:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Technorati
  • Twitter
:,

Commenti

Lascia il tuo commento:

Cerchi qualcosa?

Usa questo form per cercare argomenti in questo blog:

Non riesci a trovare quello che cerchi? Lascia un commento in un post oppure contattami per risolvere il problema!

Puoi trovarmi su Twitter come @superbre