Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6654145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:21:18+00:00 2026-05-26T01:21:18+00:00

I have a batch file which performs the operation of listening to the microphone

  • 0

I have a batch file which performs the operation of listening to the microphone and converting it to text (i am using pocket sphinx).

The command I am using to run the batch file is pocketsphinx_continuous.exe -dict <dict name> -lm <language model> -hmm <acoustic model location>. The batch file starts off and keeps listening to the microphone. Whenever we finish speaking a sentence it converts it into text on the command prompt. Since this continuously running we terminate this task by Ctrl–C.

I was trying to make this into a standalone Java application. I wanted to run this batch file through Java, so i used Runtime.getRuntime().exec("cmd /c start pocketsphinx_continuous.exe ...") with all the parameters. However strangely, it starts the batch process in a separate command prompt but immediately exits. I tried to use process.waitfor(), however it simply starts executing the batch process and then terminates. I havent called process.destroy, so i am unable to figure out why it exits the batch process.

The other question is since the batch file is running continuously, after every spoken sentence has been transcribed , I wish to get the output in my Java application. I know i can redirect the batch process to a file and then read the file, was just wondering if there is a more direct process. Could you please help me figure out where I am making a mistake.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:21:19+00:00Added an answer on May 26, 2026 at 1:21 am

    You should use Process.getInputStream() and Process.getErrorStream() to find out what messages it prints out.

    If it is exiting instantly, you might need to get the exit code (Process.waitFor()) and check the error logs from the error stream.

    Also, if you can post some of your code we might be able to help. In general, these problems are due to incorrectly configured paths or command strings.

    A possible fix would be to use the ProcessBuilder from Java 1.5 thusly:

    // Note the lack of "cmd \c" - you shouldn't need to run it in a cmd window!
    ProcessBuilder pb = new ProcessBuilder("pocketsphinx_continuous.exe",
                                           "dict", "1121.dic",
                                           "-lm", "1121.lm",
                                           "-hmm", "hub4/hmm");
    
    Process p = pb.start();
    
    // TODO for you:
    // 1. Create Threads to handle the input
    // 2. Store the Process instance so that you can call p.destroy() later.
    // 3. If interested, have a Thread doing p.waitFor() to get the exit code.
    

    As Joachim Sauer mentioned in the comments, this Javaworld article explains a lot of the gotchas associated with the Process API, so have a read through. I haven’t had a chance to play with the improvements made in JDK7 to the Process API, and by the looks of things Oracle are improving it again for JDK8 (JEP 102).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a batch file running which spits out a text/html file. The batch
I have a batch file which loops through a content of a text file
I have a batch file which I need to run at a specific date
I have one batch file (.bat) which contains text like: osql -S %ServerName% -d
I have a lovely AppleScript droplet which performs OCR of a PDF file using
I like to have a batch file which checks if an entered text in
I have a batch file which runs a java class using maven which depends
I have a batch file which is in a directory and must be run
I have a Batch file which will call a Powershell Script : BATCH FILE
I have a problem. I have a batch file which imitates the UNIX cd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.