Can we run festival.exe through java?

184 Views Asked by At

I am trying to run festival.exe through java. I tried running the following code but apparently it is not working. Where is it going wrong?

    String [] cmdArray= {"C://Festival//festival.exe","(SayText \"Hello\")"};
    Runtime rt = Runtime.getRuntime();
    rt.exec(cmdArray);

I have even tried:

    Process process = new ProcessBuilder("C:\\festival\\festival.exe","(SayText \"Hello\")").start();
    InputStream is = process.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line;

    System.out.printf("Output of running %s is:", Arrays.toString(args));

    while ((line = br.readLine()) != null) {
      System.out.println(line);
    }

This is also giving blank output and not working.

1

There are 1 best solutions below

2
green marker On

Instead of calling command line process, it's best to use on of APIs provided by Festival.

Sample Java client can be found here: https://github.com/festvox/festival/blob/master/src/modules/java/cstr/festival/Client.java