Results 1 to 3 of 3
  1. #1
    Desh Banks is offline Member
    Join Date
    Nov 2010
    Posts
    12
    Rep Power
    0

    Default Java TTS on Ubuntu with Festival

    So I have festival installed & working, and am trying to interface in a primivite way by the following:

    Java Code:
    try {
    			Runtime rt = Runtime.getRuntime();
    			rt.exec("text2wave out.txt -o sound.wav");
    			Thread.sleep(15000); // wait a couple seconds while the file is
    			// written...
    			rt.exec("play sound.wav");
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (InterruptedException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    The out.txt is created with text content and closed. The problem is that when play sound.wav is called, the sound file doesn't always play. The thread.sleep is there to try and workaround any 'file not yet written/saved' issues that may becausing this, and I noticed that when I increase the sleeptime, it works with small text samples. With larger text samples, I only get the first word or so to play, and it cuts out.

    Edit: I have tried looking to see if the file is written before the program terminates via another teminal, and it appears that the sound file is written plenty fast enough.

    Anyone tried this before/have any suggestions? Thanks.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default

    The Runtime.exec( ... ) method returns a Process object. Instead of sleeping (and hopefully long enough for the process to have finished) you can call a Process.waitFor() method until it has finished. That way you wait just long enough.

    kind regards,

    Jos

    ps. have you looked at freetts?
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Desh Banks is offline Member
    Join Date
    Nov 2010
    Posts
    12
    Rep Power
    0

    Default

    Great, just what I was looking for. Thanks - and that waitFor() bit will help with other applications I have already started work on. I should spend more time with the API I think...

Similar Threads

  1. setting classpath for java in ubuntu
    By kulangotski in forum Java Servlet
    Replies: 0
    Last Post: 01-03-2011, 02:18 AM
  2. Replies: 5
    Last Post: 07-07-2010, 12:50 PM
  3. starting java programming on ubuntu linux
    By hmjsaumya in forum New To Java
    Replies: 1
    Last Post: 01-23-2010, 06:28 AM
  4. Book festival in Belgium!
    By Dieter in forum Forum Lobby
    Replies: 2
    Last Post: 09-24-2009, 06:32 PM
  5. JDK @ ubuntu
    By M77 in forum New To Java
    Replies: 2
    Last Post: 09-16-2009, 08:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •