Sorry to ask for help right out of the gate. I've got pocketsphinx installed and running (Linux) but it seems like the definitions for command options are really cryptic. (https://www.mankier.com/1/pocketsphinx_continuous#-mfclogdir)
I'd like to have the ability to write to a log file without all the fluff, just the capture. And I don't see any way to get pocketsphinx to stop listening, like pause on command, or take any commands once it's running.
Could someone be kind enough to direct me to a man page that has a bit more detail? I can run it with "pocketsphinx_continuous -inmic yes" and it seems pretty accurate for me initially but I'd like to get it implemented and make it work for my application before training.
Thanks in advance.....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd like to have the ability to write to a log file without all the fluff, just the capture. And I don't see any way to get pocketsphinx to stop listening, like pause on command, or take any commands once it's running.
This has to be done throught the API like Python API
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ps_decoder_t ps; // create pocketsphinx decoder structure
cmd_ln_t config; // create configuration structure
ad_rec_t *ad; // create audio recording structure - for use with ALSA functions
int16 adbuf[4096]; // buffer array to hold audio data
uint8 utt_started, in_speech; // flags for tracking active speech - has speech started? - is speech currently happening?
int32 k; // holds the number of frames in the audio buffer
char const *hyp; // pointer to "hypothesis" (best guess at the decoded result)
int main(int argc, char *argv[]) {
config = cmd_ln_init(NULL, ps_args(), TRUE, // Load the configuration structure - ps_args() passes the default values
"-hmm", "/usr/local/share/pocketsphinx/model/en-us/en-us", // path to the standard english language model
"-lm", "custom.lm", // custom language model (file must be present)
"-dict", "custom.dic", // custom dictionary (file must be present)
"-logfn", "/dev/null", // suppress log info from being sent to screen
NULL);
ps = ps_init(config); // initialize the pocketsphinx decoder
ad = ad_open_dev("sysdefault", (int) cmd_ln_float32_r(config, "-samprate")); // open default microphone at default samplerate
while(1){
string decoded_speech = recognize_from_microphone(); // call the function to capture and decode speech
cout << "Decoded Speech: "<< decoded_speech << "\n" <<endl; // send decoded speech to screen
}
ad_close(ad); // close the microphone
}
string recognize_from_microphone(){
ad_start_rec(ad); // start recordingps_start_utt(ps); // mark the start of the utteranceutt_started=FALSE; // clear the utt_started flagwhile(1) {
k=ad_read(ad, adbuf, 4096); // capture the number of frames in the audio bufferps_process_raw(ps, adbuf, k, FALSE, FALSE); // send the audio buffer to the pocketsphinx decoderin_speech=ps_get_in_speech(ps); // test to see if speech is being detectedif(in_speech&&!utt_started) { //ifspeechhasstartedandutt_startedflagisfalseutt_started=TRUE; // then set the flag
}
if(!in_speech&&utt_started) { //ifspeechhasendedandtheutt_startedflagistrueps_end_utt(ps); // then mark the end of the utterancead_stop_rec(ad); // stop recordinghyp=ps_get_hyp(ps, NULL); // query pocketsphinx for "hypothesis" of decoded statementreturnhyp; // the function returns the hypothesisbreak; // exit the while loop and return to main
}
}
}
Not sure why the forum does that stupid formatting but whatever.
So it compiles fine but when I run it I get:
$ ./ps_boilerplate
Error opening audio device sysdefault for capture: No such entity
Segmentation fault (core dumped)
I'm not sure what's happening here, when I run pocketsphinx command line with inmic it finds it just dandy,
Last edit: L67GS 2020-06-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry to ask for help right out of the gate. I've got pocketsphinx installed and running (Linux) but it seems like the definitions for command options are really cryptic. (https://www.mankier.com/1/pocketsphinx_continuous#-mfclogdir)
I'd like to have the ability to write to a log file without all the fluff, just the capture. And I don't see any way to get pocketsphinx to stop listening, like pause on command, or take any commands once it's running.
Could someone be kind enough to direct me to a man page that has a bit more detail? I can run it with "pocketsphinx_continuous -inmic yes" and it seems pretty accurate for me initially but I'd like to get it implemented and make it work for my application before training.
Thanks in advance.....
This has to be done throught the API like Python API
Ahhh, is there something C++ based?
Thank you for the quick response
I found this, which should be perfect as my application is using a SBC much like a Rpi4:
https://www.robotrebels.org/index.php?topic=239.0
ps_boilerplate.cpp
==================================**
#include <iostream></iostream>
include <string></string>
include <pocketsphinx.h></pocketsphinx.h>
include <sphinxbase ad.h=""></sphinxbase>
include <sphinxbase err.h=""></sphinxbase>
using namespace std;
string recognize_from_microphone();
ps_decoder_t ps; // create pocketsphinx decoder structure
cmd_ln_t config; // create configuration structure
ad_rec_t *ad; // create audio recording structure - for use with ALSA functions
int16 adbuf[4096]; // buffer array to hold audio data
uint8 utt_started, in_speech; // flags for tracking active speech - has speech started? - is speech currently happening?
int32 k; // holds the number of frames in the audio buffer
char const *hyp; // pointer to "hypothesis" (best guess at the decoded result)
int main(int argc, char *argv[]) {
config = cmd_ln_init(NULL, ps_args(), TRUE, // Load the configuration structure - ps_args() passes the default values
"-hmm", "/usr/local/share/pocketsphinx/model/en-us/en-us", // path to the standard english language model
"-lm", "custom.lm", // custom language model (file must be present)
"-dict", "custom.dic", // custom dictionary (file must be present)
"-logfn", "/dev/null", // suppress log info from being sent to screen
NULL);
ps = ps_init(config); // initialize the pocketsphinx decoder
ad = ad_open_dev("sysdefault", (int) cmd_ln_float32_r(config, "-samprate")); // open default microphone at default samplerate
while(1){
string decoded_speech = recognize_from_microphone(); // call the function to capture and decode speech
cout << "Decoded Speech: "<< decoded_speech << "\n" <<endl; // send decoded speech to screen
}
ad_close(ad); // close the microphone
}
string recognize_from_microphone(){
}
Not sure why the forum does that stupid formatting but whatever.
So it compiles fine but when I run it I get:
$ ./ps_boilerplate
Error opening audio device sysdefault for capture: No such entity
Segmentation fault (core dumped)
I'm not sure what's happening here, when I run pocketsphinx command line with inmic it finds it just dandy,
Last edit: L67GS 2020-06-26