Menu

Using FreeTTS via Java Web Start & sandbox

Help
2002-04-23
2013-04-25
  • Jenny Brown

    Jenny Brown - 2002-04-23

    Error creating audio synthesizer:
    java.security.AccessControlException: access denied (java.util.PropertyPermission user.home read)

    I'm working on setting up my app to be launchable via Java Web Start, which is a method to launch a full application but with the security restrictions of an applet.  However, the security restrictions seem to be getting in the way.

    This would seem to be similar to a faq question about making it work with applets, but I can't seem to find such a thing [I thought I saw it before but can't find it now].  Additionally, I'm not sure just how security restrictions apply to java web start yet either.  I suspect I will have to sign my jar files to even be able to ask for additional permissions.

     
    • Paul Lamere

      Paul Lamere - 2002-04-23

      Jenny:

      Good to hear from you again.  

      There are some comments about JSAPI security in the JSAPI FAQ at:

      http://java.sun.com/products/java-media/speech/forDevelopers/jsapifaq.html

      I think the problem that you are seeing in particular is that JSAPI wants to read the speech.properties file in your home directory. 

      One possible solution for you will be to sign your application. Information on this can be found on the web start faq:

      http://java.sun.com/products/javawebstart/faq.html

      *** How can I enable my application to gain unrestricted access to the system?  ***

           An application requesting unresticted access must be digitally signed ...

      This link talks about how to sign jar files:

      http://java.sun.com/docs/books/tutorial/jar/sign/signing.html

      I've never actually done any of this so if you get this to work and feel so inclined (you've been very helpful in the past, as I recall), please write up a quick description on how you did it so we can add it to the FreeTTS faq, because, this is indeed a frequently asked question.

      Paul

       
    • Jenny Brown

      Jenny Brown - 2002-04-24

      Okay... progress... signing my jar files does indeed allow me to ask for permissions on the system, which are necessary for even reading the user.home system property.  Now, however, I'm running into the problem that the user does not yet have a speech.properties file.  I am next going to investigate providing that via the JNLP api meant to support properties files safely.

      I'm still experimenting; if I come up with a good solution I'll come back and write up an explanation of it.  [For now all I figured out was signing, which is plenty well documented elsewhere on the net.]

       
    • Paul Lamere

      Paul Lamere - 2002-04-24

      Jenny:

      Will Walker suggested this approach to avoid needing the speech.properties file at all. The idea is to bypass JSAPI Central and instead go directly to the FreeTTSEngineCentral to get the synthesizer. This bypasses the loading of the speech.properties file. The downside is that you have locked your application into using a particular synthesizer.  

      Here is an example of how to do this:

      /**
      * Copyright 2001 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 java.io.File;
      import java.util.Locale;

      // import javax.speech.Central;

      import com.sun.speech.freetts.jsapi.FreeTTSEngineCentral;
      import javax.speech.EngineList;
      import javax.speech.EngineCreate;
      import javax.speech.synthesis.Synthesizer;
      import javax.speech.synthesis.SynthesizerModeDesc;

      /**
      * Simple program showing how to use FreeTTS in JSAPI.
      */
      public class HelloWorld {
         
          public static void main(String[] argv) {
              try {
                  // Create a new SynthesizerModeDesc that will match the FreeTTS
                  // Synthesizer.
                  SynthesizerModeDesc desc = new SynthesizerModeDesc
                      ("Unlimited domain FreeTTS Speech Synthesizer from Sun Labs",
                       null,
                       Locale.US,
                       Boolean.FALSE,         // running?
                       null);                 // voice

                  FreeTTSEngineCentral central = new FreeTTSEngineCentral();
                  Synthesizer synthesizer = null;;

                  EngineList list = central.createEngineList(desc);

                  if (list.size() > 0) {
                      EngineCreate creator  = (EngineCreate) list.get(0);
                      synthesizer = (Synthesizer) creator.createEngine();
                  }

                  if (synthesizer == null) {
                      System.err.println("Can't find synthesizer");
                      System.exit(1);
                  }
                 
                  // get it ready to speak
                  synthesizer.allocate();
                  synthesizer.resume();
                 
                  // speak the "Hello world" string
                  synthesizer.speakPlainText("Hello, world!", null);
                 
                  // wait till speaking is done
                  synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);
                 
                  // clean up
                  synthesizer.deallocate();
              }
              catch (Exception e) {
                  e.printStackTrace();
              }

              System.exit(0);
          }
      }

      Perhaps this will be helpful.

      Paul

       
      • Anonymous

        Anonymous - 2002-09-30

        Have you tried this? I'm trying it now and getting a security exception. It seems that FreeTTSEngineCentral attempts to read from a "synthesizer.properties" file.

        ANy help is appreciated

        Rod Rinkus

         
      • Anonymous

        Anonymous - 2002-09-30

        Have you tried this? I'm trying it now and getting a security exception. It seems that FreeTTSEngineCentral attempts to read from a "synthesizer.properties" file.

        ANy help is appreciated

        Rod Rinkus

         
        • ar_lynz

          ar_lynz - 2006-02-25

          hi everybody,
          i'm doing a project using tts on netbeans ide platform, the problem occurs when i'd run the code (runtime error) indicate that either i didn't put speech.properties at either place or voice.jar might corrupted. i don't now how to encounter this problem, can you help me. below is the error and output after triggering run button.
          init:
          deps-jar:
          compile:
          run:
          NOVUSWARE : ERROR! Synthesizer not found!
          Make sure that there is a "speech.properties" file at either of these locations:
          user.home    : C:\Documents and Settings\Azlina
          java.home/lib: C:\j2sdk1.4.2_09nb\jre\lib

          java.lang.Exception: Synthesizer not found!
                  at voicepad.VoicePad.initSpeechSynthesisEngine(VoicePad.java:150)
                  at voicepad.VoicePad.init(VoicePad.java:113)
                  at voicepad.VoicePad.<init>(VoicePad.java:80)
                  at voicepad.VoicePad.main(VoicePad.java:100)
          NOVUSWARE : ERROR! initializing speech engine.java.lang.Exception: Synthesizer not found!
          NOVUSWARE : Speech engine shutdown.
          NOVUSWARE : Speech engine initialized.
          NOVUSWARE : New menu item created.
          NOVUSWARE : Open menu item created.
          NOVUSWARE : Save menu item created.
          NOVUSWARE : Exit menu item created.
          NOVUSWARE : File menu created.
          NOVUSWARE : Play menu item created.
          NOVUSWARE : Pause menu item created.
          NOVUSWARE : Resume menu item created.
          NOVUSWARE : Stop menu item created.
          NOVUSWARE : Speech menu created.
          NOVUSWARE : Menubar added.
          NOVUSWARE : VoicePad application initialized.
          java.lang.NullPointerException
                  at voicepad.VoicePad$8.actionPerformed(VoicePad.java:423)
                  at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
                  at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
                  at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
                  at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
                  at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
                  at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1113)
                  at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
                  at java.awt.Component.processMouseEvent(Component.java:5100)
                  at java.awt.Component.processEvent(Component.java:4897)
                  at java.awt.Container.processEvent(Container.java:1569)
                  at java.awt.Component.dispatchEventImpl(Component.java:3615)
                  at java.awt.Container.dispatchEventImpl(Container.java:1627)
                  at java.awt.Component.dispatchEvent(Component.java:3477)
                  at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
                  at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
                  at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
                  at java.awt.Container.dispatchEventImpl(Container.java:1613)
          NOVUSWARE : ERROR! Play menu item action.java.lang.NullPointerException
                  at java.awt.Window.dispatchEventImpl(Window.java:1606)
                  at java.awt.Component.dispatchEvent(Component.java:3477)
                  at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)
                  at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
                  at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
                  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
                  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
                  at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
          NOVUSWARE : Speech engine shutdown.
          BUILD SUCCESSFUL (total time: 6 seconds)

          thank you very much if you can help.

           
    • Philip Kwok

      Philip Kwok - 2002-10-01

      Dear Rod,

      You should avoid reading from the synthesizer.properties file. We have created a new demo at FreeTTS/demo/JSAPI/WebStartClock/JSAPIClock.java that illustrates how to make FreeTTS/JSAPI work with Java Web Start. You will need to download the latest FreeTTS release. Please take a look at it. If you're still having problems, please post again. One important thing is that in your JNLP file, you must give it <all-permissions/>. Also, show the Java Web Start console to see what exceptions you are getting.

      philip

       
    • Philip Kwok

      Philip Kwok - 2002-10-01

      Dear Rod,

      You should avoid reading from the synthesizer.properties file. We have created a new demo at FreeTTS/demo/JSAPI/WebStartClock/JSAPIClock.java that illustrates how to make FreeTTS/JSAPI work with Java Web Start. You will need to download the latest FreeTTS release. Please take a look at it. If you're still having problems, please post again. One important thing is that in your JNLP file, you must give it <all-permissions/>. Also, show the Java Web Start console to see what exceptions you are getting.

      philip

       
  • Hitesh

    Hitesh - 2010-12-24

    when run the above code ,I get the following error

    java.lang.NullPointerException
        at play1.main(play1.java:29)

    can you help me,please

     
  • Hitesh

    Hitesh - 2010-12-24

    when run the code below

    /**
    * Copyright 2001 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 java.io.File;
    import java.util.Locale;

    // import javax.speech.Central;

    import com.sun.speech.freetts.jsapi.FreeTTSEngineCentral;
    import javax.speech.EngineList;
    import javax.speech.EngineCreate;
    import javax.speech.synthesis.Synthesizer;
    import javax.speech.synthesis.SynthesizerModeDesc;

    /**
    * Simple program showing how to use FreeTTS in JSAPI.
    */
    public class HelloWorld {
       
        public static void main(String argv) {
            try {
                // Create a new SynthesizerModeDesc that will match the FreeTTS
                // Synthesizer.
                SynthesizerModeDesc desc = new SynthesizerModeDesc
                    ("Unlimited domain FreeTTS Speech Synthesizer from Sun Labs",
                     null,
                     Locale.US,
                     Boolean.FALSE,         // running?
                     null);                 // voice

                FreeTTSEngineCentral central = new FreeTTSEngineCentral();
                Synthesizer synthesizer = null;;

                EngineList list = central.createEngineList(desc);

                if (list.size() > 0) {
                    EngineCreate creator  = (EngineCreate) list.get(0);
                    synthesizer = (Synthesizer) creator.createEngine();
                }

                if (synthesizer == null) {
                    System.err.println("Can't find synthesizer");
                    System.exit(1);
                }
               
                // get it ready to speak
                synthesizer.allocate();
                synthesizer.resume();
               
                // speak the "Hello world" string
                synthesizer.speakPlainText("Hello, world!", null);
               
                // wait till speaking is done
                synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);
               
                // clean up
                synthesizer.deallocate();
            }
            catch (Exception e) {
                e.printStackTrace();
            }

            System.exit(0);
        }
    }

    I get the following error

    java.lang.NullPointerException
        at HelooWorld.main(HelloWorld.java:29)

    can you help me,please

     
  • Deepika Gohil

    Deepika Gohil - 2011-12-28

    I am getting the same
    java.lang.NullPointerException
    while running the above code. Does any one know the solution for the same?

    Thanks,
    Deepika.

     

Log in to post a comment.

MongoDB Logo MongoDB