Foro de elhacker.net

Programación => Java => Mensaje iniciado por: misterguapo30 en 15 Septiembre 2020, 02:12 am



Título: Sintetizador de voz para java
Publicado por: misterguapo30 en 15 Septiembre 2020, 02:12 am
Buenas, estoy intentando realizando en java un programa (en principio en español).

El cual se escribirá un texto en un JTextField y programa tiene que reproducir el texto mediante
una voz lo más natural posible.

He probado con fretts con speech y antes con mbrola. pero no me deja o no se cambiarle la voz.

¿ese es sintetizado mas adecuado para java o hay otro mejor?

¿Que me aconsejáis?

Gracias


Título: Re: Sintetizador de voz para java
Publicado por: rub'n en 20 Septiembre 2020, 00:50 am
Como estaras usando esa API, tienes codigo? segun si que funciona.


Título: Re: Sintetizador de voz para java
Publicado por: misterguapo30 en 20 Septiembre 2020, 00:56 am
Si, he hecho una prueba con el siguiente código:
Código
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package sonido;
  7.  
  8. import java.util.Locale;
  9. import javax.speech.Central;
  10. import javax.speech.synthesis.Synthesizer;
  11. import javax.speech.synthesis.SynthesizerModeDesc;
  12.  
  13. /**
  14.  *
  15.  * @author pcx
  16.  */
  17. public class SonidoSp {
  18.  
  19.    /**
  20.      * @param args the command line arguments
  21.      */
  22.    public static void main(String[] args) {
  23.        // TODO code application logic here
  24.  
  25.  
  26.        try {
  27.            // Set property as Kevin Dictionary
  28.            System.setProperty(
  29.                "freetts.voices",
  30.                "com.sun.speech.freetts.en.us"
  31.                    + ".cmu_us_kal.KevinVoiceDirectory");
  32.  
  33.            // Register Engine
  34.            Central.registerEngineCentral(
  35.                "com.sun.speech.freetts"
  36.                + ".jsapi.FreeTTSEngineCentral");
  37.  
  38.            // Create a Synthesizer
  39.            Synthesizer synthesizer
  40.                = Central.createSynthesizer(
  41.                    new SynthesizerModeDesc(Locale.US));
  42.  
  43.            // Allocate synthesizer
  44.            synthesizer.allocate();
  45.  
  46.            // Resume Synthesizer
  47.            synthesizer.resume();
  48.  
  49.            // Speaks the given text
  50.            // until the queue is empty.
  51.            synthesizer.speakPlainText(
  52.                "hola esto es carnaval tu p**a madre", null);
  53.            synthesizer.waitEngineState(
  54.                Synthesizer.QUEUE_EMPTY);
  55.  
  56.            // Deallocate the Synthesizer.
  57.            synthesizer.deallocate();
  58.        }
  59.  
  60.        catch (Exception e) {
  61.            e.printStackTrace();
  62.        }
  63.  
  64.    }
  65.  
  66. }
  67.  
  68.  

Gracias su interés


[MOD] para publicar código usar las etiquetas GeSHi


Título: Re: Sintetizador de voz para java
Publicado por: rub'n en 25 Septiembre 2020, 12:02 pm
Si, he hecho una prueba con el siguiente código:
Código
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package sonido;
  7.  
  8. import java.util.Locale;
  9. import javax.speech.Central;
  10. import javax.speech.synthesis.Synthesizer;
  11. import javax.speech.synthesis.SynthesizerModeDesc;
  12.  
  13. /**
  14.  *
  15.  * @author pcx
  16.  */
  17. public class SonidoSp {
  18.  
  19.    /**
  20.      * @param args the command line arguments
  21.      */
  22.    public static void main(String[] args) {
  23.        // TODO code application logic here
  24.  
  25.  
  26.        try {
  27.            // Set property as Kevin Dictionary
  28.            System.setProperty(
  29.                "freetts.voices",
  30.                "com.sun.speech.freetts.en.us"
  31.                    + ".cmu_us_kal.KevinVoiceDirectory");
  32.  
  33.            // Register Engine
  34.            Central.registerEngineCentral(
  35.                "com.sun.speech.freetts"
  36.                + ".jsapi.FreeTTSEngineCentral");
  37.  
  38.            // Create a Synthesizer
  39.            Synthesizer synthesizer
  40.                = Central.createSynthesizer(
  41.                    new SynthesizerModeDesc(Locale.US));
  42.  
  43.            // Allocate synthesizer
  44.            synthesizer.allocate();
  45.  
  46.            // Resume Synthesizer
  47.            synthesizer.resume();
  48.  
  49.            // Speaks the given text
  50.            // until the queue is empty.
  51.            synthesizer.speakPlainText(
  52.                "hola esto es carnaval tu p**a madre", null);
  53.            synthesizer.waitEngineState(
  54.                Synthesizer.QUEUE_EMPTY);
  55.  
  56.            // Deallocate the Synthesizer.
  57.            synthesizer.deallocate();
  58.        }
  59.  
  60.        catch (Exception e) {
  61.            e.printStackTrace();
  62.        }
  63.  
  64.    }
  65.  
  66. }
  67.  
  68.  

Gracias su interés


[MOD] para publicar código usar las etiquetas GeSHi


No contaba con mucho tiempo pero *hay* un api version 1.0 sobre ese synthesizer que no encuentro, tambien por lo ocupado, pero creo que este ejemplo con todas las api de terceros deberia, deberia ejecutarse bien....