SPRAAK
|
Data Structures | |
struct | SpraakWord |
struct | SpraakMon |
Structure used to provide status information to the progress monitor functions. More... | |
struct | SpraakAGC |
Structure used to provide status information to the volume monitor functions. More... | |
Namespaces | |
xref_spr_dist_mat | |
Distance matrices | |
xref_high_lvl_api_desc | |
Higher level API configuration file and table format | |
Typedefs | |
typedef struct Spraak_ * | SpraakHandler |
typedef void(* | SpraakMonFunc )(const SpraakMon *res, void *info) |
The progress monitor function. More... | |
typedef void(* | SpraakAGCfunc )(SpraakAGC *agc) |
typedef void *(* | Spraak_read_audio )(void *buf, void *stream_info, int Nbytes, int nowait) |
Enumerations | |
enum | { SPR_QSPRAAK_SAMPLE_FREQ, SPR_QSPRAAK_FRAME_SHIFT, SPR_QSPRAAK_SAMPLE_TYPE, SPR_QSPRAAK_BYTES_PER_SAMPLE, SPR_QSPRAAK_NCHAN, SPR_QSPRAAK_FRAME_SIZE, SPR_QSPRAAK_FSHIFT, SPR_QSPRAAK_FPU_MODE, SPR_QSPRAAK_CURR_LEX, SPR_QSPRAAK_CURR_LM, SPR_QSPRAAK_CURR_AM, SPR_QSPRAAK_CURR_SSP, SPR_QSPRAAK_CURR_SPKR, SPR_QSPRAAK_CURR_SETUP } |
enum | SpraakMonEvent { SPR_SPRAAK_MON_WAIT, SPR_SPRAAK_MON_START, SPR_SPRAAK_MON_OUT, SPR_SPRAAK_MON_END } |
Events for the SPRAAK monitor call-back function. More... | |
Functions | |
const char * | SPRaak_version (void) |
void * | SPRaak_close (SpraakHandler spraak) |
Deallocate the recognizer info. More... | |
const char * | SPRaak_key_get (const SpraakHandler spraak, const char *section, const char *item) |
int | SPRaak_key_get_dt (const SpraakHandler spraak, const char *section, const char *item, const SprDT *dt, void *dst) |
const char * | SPRaak_key_iterator (const SpraakHandler spraak, int *iterator) |
int | SPRaak_key_set (const SpraakHandler spraak, const char *section, const char *item, const char *value) |
int | SPRaak_key_set_dt (const SpraakHandler spraak, const char *section, const char *item, const SprDT *dt, const void *value) |
int | SPRaak_key_remove (SpraakHandler spraak, const char *section, const char *item) |
int | SPRaak_change_lex (SpraakHandler spraak, const char *lex_name) |
int | SPRaak_change_LM (SpraakHandler spraak, const char *lm_name) |
int | SPRaak_change_lex_LM (SpraakHandler spraak, const char *lex_name, const char *lm_name) |
int | SPRaak_change_ssp (SpraakHandler spraak, const char *ssp_name) |
int | SPRaak_change_spkr (SpraakHandler spraak, const char *spkr_name, int new_spkr) |
int | SPRaak_store_spkr (SpraakHandler spraak) |
int | SPRaak_change_setup (SpraakHandler spraak, const char *setup_name) |
const SpraakWord * | SPRaak_result (SpraakHandler spraak) |
char * | SPRaak_result_str (SpraakHandler spraak) |
int | SPRaak_track_lm_ini (SpraakHandler spraak, int id) |
int | SPRaak_track_lm_cpy (SpraakHandler spraak, int id_src, int id_dst) |
int | SPRaak_track_lm_step (SprDynStr *res, SpraakHandler spraak, int id, SpraakWord *winfo) |
int | SPRaak_recog_file_range (SpraakHandler spraak, const char *fname, double btime, double etime) |
int | SPRaak_recog_file (SpraakHandler spraak, const char *fname) |
int | SPRaak_recog_file_check_more (SpraakHandler spraak) |
Check if there is more data to process in the last processed file. More... | |
int | SPRaak_recog_stream_named (SpraakHandler spraak, Spraak_read_audio read_func, void *info, const char *name) |
int | SPRaak_recog_stream (SpraakHandler spraak, Spraak_read_audio read_func, void *info) |
void | SPRaak_recog_change_settings_search (SpraakHandler spraak, int max_bw, int min_bw, float threshold, float add_min_frac) |
int | SPRaak_change_settings_decode (SpraakHandler spraak) |
void | SPRaak_abort (SpraakHandler spraak, int everywhere) |
int | SPRaak_make_bin_lex (SpraakHandler spraak, const char *lex_txt_fname, const char *lex_bin_fname) |
int | SPRaak_add_lex (SpraakHandler spraak, const char *name, const char *key,...) |
Dynamically change the spraak resources. More... | |
int | SPRaak_add_LM (SpraakHandler spraak, const char *name, const char *key,...) |
Dynamically change the spraak resources. More... | |
int | SPRaak_add_ssp (SpraakHandler spraak, const char *name, const char *key,...) |
Dynamically change the spraak resources. More... | |
int | SPRaak_add_spkr (SpraakHandler spraak, const char *name, const char *key,...) |
Dynamically change the spraak resources. More... | |
int | SPRaak_add_section (SpraakHandler spraak, const char *name, const char *key,...) |
Dynamically change the spraak resources. More... | |
int | SPRaak_rm_lex (SpraakHandler spraak, const char *name) |
Dynamically change the spraak resources. More... | |
int | SPRaak_rm_LM (SpraakHandler spraak, const char *name) |
Dynamically change the spraak resources. More... | |
int | SPRaak_rm_ssp (SpraakHandler spraak, const char *name) |
Dynamically change the spraak resources. More... | |
int | SPRaak_rm_spkr (SpraakHandler spraak, const char *name) |
Dynamically change the spraak resources. More... | |
int | SPRaak_rm_section (SpraakHandler spraak, const char *name) |
Dynamically change the spraak resources. More... | |
int | SPRaak_mon_recog (SpraakHandler spraak, SpraakMonFunc monitor_func, void *info) |
(Un)install a function to monitor the progress of the speech recognition. More... | |
int | SPRaak_mon_volume (SpraakHandler spraak, const char *agc_name, SpraakAGCfunc func, void *info) |
SpraakHandler | SPRaak_init (const char *config_fname) |
int | SPRaak_query (SpraakHandler spraak, int request, void *res) |
typedef struct Spraak_* SpraakHandler |
typedef void(* SpraakMonFunc)(const SpraakMon *res, void *info) |
The progress monitor function.
See SPRaak_mon_recog() for more details.
typedef void(* SpraakAGCfunc)(SpraakAGC *agc) |
The volume monitor function, see SPRaak_mon_volume() for more details.
typedef void*(* Spraak_read_audio)(void *buf, void *stream_info, int Nbytes, int nowait) |
The get audio call-back function, see SPRaak_recog_stream() for more details.
anonymous enum |
Query certain properties from the SPRAAK system, see SPRaak_query() for more details.
enum SpraakMonEvent |
Events for the SPRAAK monitor call-back function.
See SPRaak_mon_recog() for more details.
Enumerator | |
---|---|
SPR_SPRAAK_MON_WAIT | |
SPR_SPRAAK_MON_START | |
SPR_SPRAAK_MON_OUT | |
SPR_SPRAAK_MON_END |
const char* SPRaak_version | ( | void | ) |
void* SPRaak_close | ( | SpraakHandler | spraak | ) |
Deallocate the recognizer info.
spraak | The SPRAAK handler as returned by SPRaak_init() (or NULL). |
const char* SPRaak_key_get | ( | const SpraakHandler | spraak, |
const char * | section, | ||
const char * | item | ||
) |
Search for a key section.item in the SPRAAK configuration table (read from the initialisation file, possible modified later on). If the key is not found, a NULL is returned. Instead of specifying section and item, both can be specified as "section.item" in the section parameter and a NULL for the item parameter.
spraak | The SPRAAK handler as returned by SPRaak_init(). |
section | [section] |
item | item |
int SPRaak_key_get_dt | ( | const SpraakHandler | spraak, |
const char * | section, | ||
const char * | item, | ||
const SprDT * | dt, | ||
void * | dst | ||
) |
Search for the key section.item in the SPRAAK configuration table (read from the initialisation file, possible modified later on) and check if its value can be converted to a something of the the type dt, i.e. check if the key can be found and if its value is a well formed integer, float, ...
If the all is OK, the binary value is stored to *dst. Typical values for dt are:
For more details on the parameters section and item, see SPRaak_key_get().
spraak | The SPRAAK handler as returned by SPRaak_init(). |
section | [section] |
item | item |
dt | Data type. |
dst | Destination. |
const char* SPRaak_key_iterator | ( | const SpraakHandler | spraak, |
int * | iterator | ||
) |
Iterate over all keys in the SPRAAK configuration table.
Example code:
spraak | The SPRAAK handler as returned by SPRaak_init(). |
int SPRaak_key_set | ( | const SpraakHandler | spraak, |
const char * | section, | ||
const char * | item, | ||
const char * | value | ||
) |
Store the user key section.item and associated value value in the SPRAAK configuration table. For more details on the parameters section and item, see SPRaak_key_get().
spraak | The SPRAAK handler as returned by SPRaak_init(). |
section | [section] |
item | item |
value | Value to the set key to. |
int SPRaak_key_set_dt | ( | const SpraakHandler | spraak, |
const char * | section, | ||
const char * | item, | ||
const SprDT * | dt, | ||
const void * | value | ||
) |
Store the user key section.item and associated value value of type dt in the SPRAAK configuration table. For more details on the parameters section and item, see SPRaak_key_get(). For more details on the parameter dt, see SPRaak_key_get_dt(). For more details on the restrictions of this routine, see SPRaak_key_set().
spraak | The SPRAAK handler as returned by SPRaak_init(). |
section | [section] |
item | item |
dt | Data type of value. |
value | Binary value (of the type dt). |
int SPRaak_key_remove | ( | SpraakHandler | spraak, |
const char * | section, | ||
const char * | item | ||
) |
Remove the key section.item and its associated value from the spraak configuration table. For more details on the parameters section and item, see SPRaak_key_get(). For more details on the restrictions of this routine, see SPRaak_key_set().
spraak | The SPRAAK handler as returned by SPRaak_init(). |
section | [section] |
item | item |
int SPRaak_change_lex | ( | SpraakHandler | spraak, |
const char * | lex_name | ||
) |
Load a new lexicon and adjust the search parameters. The first argument must be the pointer previously returned by SPRaak_init(), the second argument must be a name of a lexicon section as defined in the configuration file. The new lexicon will be linked with the existing language model (see SPRaak_change_lex_LM() when you want to change both the lexicon and the LM).
int SPRaak_change_LM | ( | SpraakHandler | spraak, |
const char * | lm_name | ||
) |
Load a new language model and adjust the search parameters. The first argument must be the pointer previously returned by SPRaak_init(), the second argument must be a name of a language model section as defined in the configuration file.
int SPRaak_change_lex_LM | ( | SpraakHandler | spraak, |
const char * | lex_name, | ||
const char * | lm_name | ||
) |
Load a new lexicon and language model, and adjust the search parameters. The first argument must be the pointer previously returned by SPRaak_init(), the second and third argument must be a name of a lexicon and language model section respectively as defined in the configuration file.
int SPRaak_change_ssp | ( | SpraakHandler | spraak, |
const char * | ssp_name | ||
) |
Load a new preprocessing.
spraak | The SPRAAK handler as returned by SPRaak_init(). |
ssp_name | Name of a preprocessing section as defined in the SPRAAK configuration table. |
int SPRaak_change_spkr | ( | SpraakHandler | spraak, |
const char * | spkr_name, | ||
int | new_spkr | ||
) |
(Re)load or create a (new) speaker profile. If the new_spkr flag is set, a new speaker profile is created, otherwise an existing profile (created by SPRaak_store_spkr()) is (re)loaded.
spraak | The SPRAAK handler as returned by SPRaak_init(). |
spkr_name | Name of a speaker section as defined in the SPRAAK configuration table. |
new_spkr | Indicate a new speaker. |
int SPRaak_store_spkr | ( | SpraakHandler | spraak | ) |
Store the current speaker profile.
spraak | The SPRAAK handler as returned by SPRaak_init(). |
int SPRaak_change_setup | ( | SpraakHandler | spraak, |
const char * | setup_name | ||
) |
Load a new setup (combination of acoustic model, language model, lexicon, preprocessing ans speaker info). Missing components are derived from the [default] section.
spraak | The SPRAAK handler as returned by SPRaak_init(). |
setup_name | Name of a setup section as defined in the SPRAAK configuration table. |
const SpraakWord* SPRaak_result | ( | SpraakHandler | spraak | ) |
Get the result of the recogniser.
spraak | The SPRAAK handler as returned by SPRaak_init(). |
char* SPRaak_result_str | ( | SpraakHandler | spraak | ) |
Get the result of the recogniser and put in in a string.
spraak | The SPRAAK handler as returned by SPRaak_init(). |
int SPRaak_track_lm_ini | ( | SpraakHandler | spraak, |
int | id | ||
) |
Initialize one of the four LM-status buffer to the empty LM-context.
spraak | The SPRAAK handler as returned by SPRaak_init(). |
id | Id of the LM-status buffer. |
int SPRaak_track_lm_cpy | ( | SpraakHandler | spraak, |
int | id_src, | ||
int | id_dst | ||
) |
Copy the content of LM-status buffer id_src to LM-status buffer id_dst.
spraak | The SPRAAK handler as returned by SPRaak_init(). |
id_src | Id of the source LM-status buffer. |
id_dst | Id of the destination LM-status buffer. |
int SPRaak_track_lm_step | ( | SprDynStr * | res, |
SpraakHandler | spraak, | ||
int | id, | ||
SpraakWord * | winfo | ||
) |
Add word winfo to the LM-status buffer with id id. This operation has the following effect and outputse:
res | Return the textual explanation of the LM operation. |
spraak | The SPRAAK handler as returned by SPRaak_init(). |
id | Id of the LM-status buffer. |
winfo | Word info. |
int SPRaak_recog_file_range | ( | SpraakHandler | spraak, |
const char * | fname, | ||
double | btime, | ||
double | etime | ||
) |
Start the speech recognition for the audio file fname for the data in the range [btime,etime[ (btime and etime are expressed in seconds). An end time of -1.0 means till the end of the file. A begin time of -1.0 means from the current position (or the start of the file). The recognition will stop at etime or at the end of the first sentence if a "SENTENCE_DETECTOR" is installed (preprocessing). In the latter case, the next sentence(s) call be processed by recalling this routine with fname set to NULL (and most likely btime set to -1.0).
spraak | The SPRAAK handler as returned by SPRaak_init(). |
fname | Path to the audio file. |
int SPRaak_recog_file | ( | SpraakHandler | spraak, |
const char * | fname | ||
) |
This function is a shortcut for
spraak | The SPRAAK handler as returned by SPRaak_init(). |
fname | Path to the audio file. |
int SPRaak_recog_file_check_more | ( | SpraakHandler | spraak | ) |
Check if there is more data to process in the last processed file.
see SPRaak_recog_file(). This is only relevant when a "SENTENCE_DETECTOR" is installed (preprocessing).
spraak | The SPRAAK handler as returned by SPRaak_init(). |
int SPRaak_recog_stream_named | ( | SpraakHandler | spraak, |
Spraak_read_audio | read_func, | ||
void * | info, | ||
const char * | name | ||
) |
Recognize Start the speech recognition for non file-based audio input.
The read function read_func will be called whenever an extra frame of audio data is needed:
The read_func then must either return a pointer to Nbytes bytes of audio data or return a NULL. Typically, the buffer buf is used to stored the audio data, but this is not necessary. Any buffer that will be persitent untill the next call to the read function read_func will do. The end of the data is indicated by returning a NULL value. The nowait flag is currently alway 0 (but is reserved for future use).
The recognition will stop when the end of the audio is reached (read_func returns a NULL) or at the end of the first sentence if a "SENTENCE_DETECTOR" is installed (preprocessing).
spraak | The SPRAAK handler as returned by SPRaak_init(). |
read_func | The call-back function that must provide the audio. |
info | Extra info for the call-back function. |
int SPRaak_recog_stream | ( | SpraakHandler | spraak, |
Spraak_read_audio | read_func, | ||
void * | info | ||
) |
This function is a shortcut for
spraak | The SPRAAK handler as returned by SPRaak_init(). |
read_func | The call-back function that must provide the audio. |
info | Extra info for the call-back function. |
void SPRaak_recog_change_settings_search | ( | SpraakHandler | spraak, |
int | max_bw, | ||
int | min_bw, | ||
float | threshold, | ||
float | add_min_frac | ||
) |
Update the parameters that control the decoding speed. This function can be called during decoding, typically from a monitor call-back function. Arguments set to -1 (or -1.0) will be left unchanged.
spraak | Handler previously returned by SPRaak_init(). |
max_bw | New maximum beam width. |
min_bw | New minimum beam width. |
threshold | New pruning threshold. |
add_min_frac | New threshold upgrade factor. |
int SPRaak_change_settings_decode | ( | SpraakHandler | spraak | ) |
Retrieve all settings related to the decoding process (LM-factors, pruning thresholds, ...) and update them. This function can only be called when the recognizer is off-line.
spraak | Handler previously returned by SPRaak_init(). |
void SPRaak_abort | ( | SpraakHandler | spraak, |
int | everywhere | ||
) |
The argument spraak is the pointer to the recognition structure returned by SPRaak_init(). The argument everywhere allows you to select one of two abort modes. When everywhere is 0, a simple end-of-file (EOF) is simulated the next time a frame (10 msec of speech signal) is read. The words recognized up till know are returned as the final recognition result, both by the spraak monitor function as well as through the normal return system of the the SPRaak_recog_*() functions.
When everywhere is 1, an imediate break from every SPRaak_*() routine is requested. This goes faster as we don't have to wait until the current frame (10 msec of speech signal) is processed. This mode also aborts when you are doing something else than recognizing speech (e.g. loading a new lexicon or language model). When aborting the recognition process, the recognition result are discarded and the SPRaak_recog_*() functions return a (-1). The spraak monitor function is NOT called (not even with the value SPRAAK_MON_END).
spraak | Handler previously returned by SPRaak_init(). |
int SPRaak_make_bin_lex | ( | SpraakHandler | spraak, |
const char * | lex_txt_fname, | ||
const char * | lex_bin_fname | ||
) |
Read the ascii lexicon lex_txt_fname and write it back in binary format to the file lex_bin_fname. When converting, the options specified with the current active lexicon setup are used to convert the lexicon. Furthermore, at the end of the conversion, the lexicon (the field 'file' in the lexicon section) attached to the current active lexicon setup is replaced by the newly created binary lexicon. Note that this replacement happens only in the memory of your computer, the SPRaak.ini file is not altered. Hence the replacement only holds for the duration of the program run (see remark2 how a lasting replacement can be obtained).
spraak | Handler previously returned by SPRaak_init(). |
lex_txt_fname | Input: text based lexicon description. |
lex_bin_fname | Output: lexicon in binary format. |
int SPRaak_add_lex | ( | SpraakHandler | spraak, |
const char * | name, | ||
const char * | key, | ||
... | |||
) |
Dynamically change the spraak resources.
add a new lexicon section (with and configuration settings). The list of key and value strings must be terminated by a NULL pointer.
spraak | Handler previously returned by SPRaak_init(). |
name | Name of the lexicon section (without the 'LEX:' prefix). |
key | NULL terminated argument list of keys and values. |
int SPRaak_add_LM | ( | SpraakHandler | spraak, |
const char * | name, | ||
const char * | key, | ||
... | |||
) |
Dynamically change the spraak resources.
add a new language model (with and configuration settings). The list of key and value strings must be terminated by a NULL pointer.
spraak | Handler previously returned by SPRaak_init(). |
name | Name of the LM section (without the 'LM:' prefix). |
key | NULL terminated argument list of keys and values. |
int SPRaak_add_ssp | ( | SpraakHandler | spraak, |
const char * | name, | ||
const char * | key, | ||
... | |||
) |
Dynamically change the spraak resources.
add a new preprocessing (with and configuration settings). The list of key and value strings must be terminated by a NULL pointer.
spraak | Handler previously returned by SPRaak_init(). |
name | Name of the preprocessing section (without the 'SSP:' prefix). |
key | NULL terminated argument list of keys and values. |
int SPRaak_add_spkr | ( | SpraakHandler | spraak, |
const char * | name, | ||
const char * | key, | ||
... | |||
) |
Dynamically change the spraak resources.
add a new speaker (with given name and configuration settings). The list of key and value strings must be terminated by a NULL pointer.
spraak | Handler previously returned by SPRaak_init(). |
name | Name of the speaker section (without the 'SPKR:' prefix). |
key | NULL terminated argument list of keys and values. |
int SPRaak_add_section | ( | SpraakHandler | spraak, |
const char * | name, | ||
const char * | key, | ||
... | |||
) |
Dynamically change the spraak resources.
add a new 'non resource!' section (with given name and configuration settings). The list of key and value strings must be terminated by a NULL pointer.
spraak | Handler previously returned by SPRaak_init(). |
name | Name of the section. |
key | NULL terminated argument list of keys and values. |
int SPRaak_rm_lex | ( | SpraakHandler | spraak, |
const char * | name | ||
) |
Dynamically change the spraak resources.
remove a lexicon.
int SPRaak_rm_LM | ( | SpraakHandler | spraak, |
const char * | name | ||
) |
Dynamically change the spraak resources.
remove a lexicon section.
int SPRaak_rm_ssp | ( | SpraakHandler | spraak, |
const char * | name | ||
) |
Dynamically change the spraak resources.
remove a preprocessing section.
spraak | Handler previously returned by SPRaak_init(). |
name | Name of the preprocessing section. |
int SPRaak_rm_spkr | ( | SpraakHandler | spraak, |
const char * | name | ||
) |
Dynamically change the spraak resources.
remove a speaker section.
spraak | Handler previously returned by SPRaak_init(). |
name | Name of the speaker section. |
int SPRaak_rm_section | ( | SpraakHandler | spraak, |
const char * | name | ||
) |
Dynamically change the spraak resources.
remove a 'non resource!' section.
spraak | Handler previously returned by SPRaak_init(). |
name | Name of the section. |
int SPRaak_mon_recog | ( | SpraakHandler | spraak, |
SpraakMonFunc | monitor_func, | ||
void * | info | ||
) |
(Un)install a function to monitor the progress of the speech recognition.
The monitor function is called at the following events:
The monitor function is called with the following arguments:
with res a structure that contains the recognized words so far, and info the pointer that was specified when installing the monitor function.
The monitor function can be uninstalled by sepcifying a NULL pointer as monitor_func argument.
monitor_func | Monitor function. |
info | Extra info that will be passed to the monitor function. |
int SPRaak_mon_volume | ( | SpraakHandler | spraak, |
const char * | agc_name, | ||
SpraakAGCfunc | func, | ||
void * | info | ||
) |
(Un)install a function to monitor the audio volume. The monitor is called periodically (the call frequency can be set in the AGC function in the preprocessing).
The monitor function is called with as single argument something of the type SPRaakAGC which has the following usefull elements:
agc_name | Name of the AGC allows for multiple AGC's (e.g. stereo). |
func | Monitor function. |
info | Extra info that will be passed to the monitor function. |
SpraakHandler SPRaak_init | ( | const char * | config_fname | ) |
Initialize the recognizer for a certain language, i.e. load an acoustic model, lexicon and language model as defined in the configuration file config_fname. The directory of the configuration file is used as base directory for loading the other components, hence avoiding the need for absolute paths in the configuration files.
config_fname | Configuration file. |
int SPRaak_query | ( | SpraakHandler | spraak, |
int | request, | ||
void * | res | ||
) |
Query the SPRAAK system about some inferred or run-time parameters. The request argument specifies the quantity that is requested. The res argument is the pointer to were the requested value is (int, double of char*) written. The possible values for request and their return types are:
spraak | Handler previously returned by SPRaak_init(). |
request | Request type. |
res | Location to store the result. |