Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add -infile option to read from pre-recorded wav file #47

Closed
Sispheor opened this issue Sep 2, 2016 · 1 comment
Closed

add -infile option to read from pre-recorded wav file #47

Sispheor opened this issue Sep 2, 2016 · 1 comment

Comments

@Sispheor
Copy link

Sispheor commented Sep 2, 2016

For testing, I would like to record my voice and give the recorded sample to snowboy for testing my script without having to speak into my microphone everytime.

On pocket_sphinx continus there is an option to do that
pocketsphinx_continuous -infile file.wav

@chenguoguo
Copy link
Collaborator

This is easily doable, but you might have to modify the code a little bit.

Taking the C++ demo as an example,

  std::cout << "Listening... Press Ctrl+C to exit" << std::endl;
  std::vector<int16_t> data;
  while (true) {
    pa_wrapper.Read(&data);
    if (data.size() != 0) {
      int result = detector.RunDetection(data.data(), data.size());
      if (result > 0) {
        std::cout << "Hotword " << result << " detected!" << std::endl;
      }
    }
  }

What you have to do is, instead of reading the data using pa_wrapper.Read(&data); which calls PortAudio and captures audio through the microphone, you should read the data from audio file. Make sure your audio file is in the correct format (16k sampling rate, 1 channel, 16 bit signed integer), linear PCM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants