SPRAAK
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Namespaces | Typedefs | Enumerations | Functions
API_HighLvl::lib::cwr
+ Collaboration diagram for API_HighLvl::lib::cwr:

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 SpraakWordSPRaak_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)
 

Detailed Description

Typedef Documentation

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.

Enumeration Type Documentation

anonymous enum

Query certain properties from the SPRAAK system, see SPRaak_query() for more details.

Enumerator
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 

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 

Function Documentation

const char* SPRaak_version ( void  )
Returns
the version string.
void* SPRaak_close ( SpraakHandler  spraak)

Deallocate the recognizer info.

Returns
a NULL pointer.
Parameters
spraakThe 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.

Returns
The value associated to the key as a string, or NULL if the key was not found.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
section[section]
itemitem
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:

spr_dt_int
An integer
spr_dt_long
A long integer
spr_dt_size
Some size (an integer or a long integer)
spr_dt_f32
A float
spr_dt_f64
A double

For more details on the parameters section and item, see SPRaak_key_get().

Returns
(1)
if the key was found and could be successfully converted;
(0)
if the key was not found;
(-1)
if the key was found but could not be converted to something of the type dt.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
section[section]
itemitem
dtData type.
dstDestination.
const char* SPRaak_key_iterator ( const SpraakHandler  spraak,
int *  iterator 
)

Iterate over all keys in the SPRAAK configuration table.
Example code:

for(int ndx=0;(key=SPRaak_query_iterator(spraak,&ndx))!=NULL; )
{// do something with the key
}
Returns
(NULL) if no more keys are available.
Note
The resource table should not be modified during the loop.
Parameters
spraakThe 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().

Returns
0 on success and -1 on failure (key already exists, trying to change a resource, ...).
Note
If you want to modify an existing key, first remove and then set it again.
The name spaces (sections) asociated with spraak resources ([AM:...], [SSP:...], [LEX:...], [LM:...], [SPKR:...]) may not be altered by this function, as this could lead to undefined behaviour. Use the resource specific routines instead.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
section[section]
itemitem
valueValue 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().

Returns
0 on success and -1 on failure (key already exists, trying to change a resource, ...).
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
section[section]
itemitem
dtData type of value.
valueBinary 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().

Returns
1 when the key was found and removed, 0 otherwise.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
section[section]
itemitem
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).

Returns
(-1) on error, 0 otherwise.
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.

Returns
(-1) on error, 0 otherwise.
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.

Returns
(-1) on error, 0 otherwise.
int SPRaak_change_ssp ( SpraakHandler  spraak,
const char *  ssp_name 
)

Load a new preprocessing.

Returns
0 on success and -1 on failure.
Note
After loading a new preprocessing, all speaker setting related to the preprocessing pipeline are reset to speaker independent default values. The application must save and/or restore the speakers setting around a change in the preprocessing.
Rationale: speaker settings across different preprocessings may be incompatible (more or less parameters, ...).
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
ssp_nameName 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.

Returns
0 on success and -1 on failure.
Note
the speaker section spkr_name must exist and be valid, even for a new speaker.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
spkr_nameName of a speaker section as defined in the SPRAAK configuration table.
new_spkrIndicate a new speaker.
int SPRaak_store_spkr ( SpraakHandler  spraak)

Store the current speaker profile.

Returns
0 on success and -1 on failure.
Parameters
spraakThe 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.

Returns
0 on success and -1 on failure.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
setup_nameName of a setup section as defined in the SPRAAK configuration table.
const SpraakWord* SPRaak_result ( SpraakHandler  spraak)

Get the result of the recogniser.

Returns
An array of SpraakWord elements. The length of the array was returned by SPRaak_recog_stream() or SPRaak_recog_file(). A NULL is returned if and only if SPRaak_recog_stream() or SPRaak_recog_file() returned -1.
Parameters
spraakThe 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.

Returns
A string containing all the words separated by a single space. On failure, a NULL is returned.
Parameters
spraakThe 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.

Returns
(-1) on failure, (0) otherwise.
Note
will reset the other LM-status buffers as well if the LM changed.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
idId 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.

Returns
(-1) on failure, (0) otherwise.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
id_srcId of the source LM-status buffer.
id_dstId 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:

  1. the LM-status buffer is updated to the new LM-context,
  2. the dynamic string *res will contain a textual description of the LM operations taken to get to the new LM-context,
  3. the resulting LM-probability is stored in winfo->lm_fwd
Returns
(-1) on failure, (0) otherwise.
Parameters
resReturn the textual explanation of the LM operation.
spraakThe SPRAAK handler as returned by SPRaak_init().
idId of the LM-status buffer.
winfoWord 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).

Note
the preprocessing will be reset at the start of each file (i.e. whenever fname is not NULL), even if the same file is processed twice.
rewinding the file (start recognizing earlier than the previous end-point) may not work on all files and may incur a large overhead.
Returns
the number of words recognized, or (-1) in case of an error. A return value of 0 means that no sentence was found by the silence/speech detector.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
fnamePath to the audio file.
int SPRaak_recog_file ( SpraakHandler  spraak,
const char *  fname 
)

This function is a shortcut for

SPRaak_recog_file_range(spraak,fname,-1.0,-1.0)
See Also
SPRaak_recog_file_range() for more details.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
fnamePath 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).

Returns
1 when more data is available, 0 otherwise.
Parameters
spraakThe 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:

void *read_func(void *buf,void *info,int Nbytes,int nowait)

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).

Note
the signal preprocessing is reset whenenver name is not NULL (even if the same name is specified); the first call to this function must specify a valid (i.e. non NULL) name.
Returns
the number of words recognized, or (-1) in case of an error. A return value of 0 means that no sentence was found by the silence/speech detector.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
read_funcThe call-back function that must provide the audio.
infoExtra 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_recog_stream_named(spraak,read_func,info,"stream.raw")
See Also
SPRaak_recog_stream_named() for more details.
Parameters
spraakThe SPRAAK handler as returned by SPRaak_init().
read_funcThe call-back function that must provide the audio.
infoExtra 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.

Note
The changes will be applied when the recognizer sees is fit.
Parameters
spraakHandler previously returned by SPRaak_init().
max_bwNew maximum beam width.
min_bwNew minimum beam width.
thresholdNew pruning threshold.
add_min_fracNew 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.

Returns
-1 on failure and 0 otherwise.
Parameters
spraakHandler 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).

Note
Stopping with everywhere set to 1, may not be a 100% robust: the recognizer will execute lots of exception code (code that is normally only executed in extreme circumstances, such as running out of memory), and this exception code is not very well validated since it is almost never needed.
Parameters
spraakHandler 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).

Note
The lexicon specified in the current active lexicon setup (the field 'file' in the lexicon section) must always point to a usable lexicon (binary or ascii) lexicon. You can for example use a lexicon containing only the word '</s>' as place holder for the real thing that gets swapped in using the SPRaak_make_bin_lex() function.
A possible setup where the SPRaak_make_bin_lex() comes in handy, is when users can add, remove or edit words from the base lexicon. In such a setup, the field 'file' in the lexicon section should point to the binary version of the lexicon. Changes are done in the asci version, and then the SPRaak_make_bin_lex() function is called to convert the edited ascii lexicon to an updated binary lexicon, overwriting the old binary lexicon. Hence, at the next start of the program, the updated binary lexicon will be loaded (and the whole process can be repeated if new changes are needed).
Parameters
spraakHandler previously returned by SPRaak_init().
lex_txt_fnameInput: text based lexicon description.
lex_bin_fnameOutput: 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.

Returns
(-1) on error, and 0 otherwise.
Parameters
spraakHandler previously returned by SPRaak_init().
nameName of the lexicon section (without the 'LEX:' prefix).
keyNULL 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.

Returns
(-1) on error, and 0 otherwise.
Parameters
spraakHandler previously returned by SPRaak_init().
nameName of the LM section (without the 'LM:' prefix).
keyNULL 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.

Returns
(-1) on error, and 0 otherwise.
Parameters
spraakHandler previously returned by SPRaak_init().
nameName of the preprocessing section (without the 'SSP:' prefix).
keyNULL 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.

Returns
(-1) on error, and 0 otherwise.
Parameters
spraakHandler previously returned by SPRaak_init().
nameName of the speaker section (without the 'SPKR:' prefix).
keyNULL 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.

Returns
(-1) on error, and 0 otherwise.
Parameters
spraakHandler previously returned by SPRaak_init().
nameName of the section.
keyNULL terminated argument list of keys and values.
int SPRaak_rm_lex ( SpraakHandler  spraak,
const char *  name 
)

Dynamically change the spraak resources.

remove a lexicon.

Returns
(-1) on error, and 0 otherwise.
int SPRaak_rm_LM ( SpraakHandler  spraak,
const char *  name 
)

Dynamically change the spraak resources.

remove a lexicon section.

Returns
(-1) on error, and 0 otherwise.
int SPRaak_rm_ssp ( SpraakHandler  spraak,
const char *  name 
)

Dynamically change the spraak resources.

remove a preprocessing section.

Returns
(-1) on error, and 0 otherwise.
Note
The current active preprocessing cannot be removed.
Parameters
spraakHandler previously returned by SPRaak_init().
nameName of the preprocessing section.
int SPRaak_rm_spkr ( SpraakHandler  spraak,
const char *  name 
)

Dynamically change the spraak resources.

remove a speaker section.

Returns
(-1) on error, and 0 otherwise.
Note
The current active speaker cannot be removed.
Parameters
spraakHandler previously returned by SPRaak_init().
nameName of the speaker section.
int SPRaak_rm_section ( SpraakHandler  spraak,
const char *  name 
)

Dynamically change the spraak resources.

remove a 'non resource!' section.

Returns
(-1) on error, and 0 otherwise.
Parameters
spraakHandler previously returned by SPRaak_init().
nameName 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:

SPRAAK_MON_WAIT
silence/speech detection started.
SPRAAK_MON_START
the silence/speech detector has detected the start of a sentence; recognition will start from here on.
SPRAAK_MON_OUT
one or more new words were fixated, i.e. it is now certain that these words will be part of the recognised sentence – or – the timer has expired (useful to show that we are still doing something).
SPRAAK_MON_END
the silence/speech detector has reported the end of a sentence (or the end of the file has been reached); recognition will end here.

The monitor function is called with the following arguments:

monitor_func(SPRaakMon *res,void *info)

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.

Returns
0 on success and (-1) (-1) if the monitor hook could not be installed (out of memory).
Parameters
monitor_funcMonitor function.
infoExtra 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:

energy
normalized energy (max=1.0)
maxval
maximum sample value (normalized). Values larger or equal to 1 indicate clipping.
maxavg
maximum sample value (normalized) averaged over the frames in the fragment
Returns
0 on success and (-1) if the monitor hook could not be installed (out of memory).
Parameters
agc_nameName of the AGC
allows for multiple AGC's (e.g. stereo).
funcMonitor function.
infoExtra 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.

Returns
a unique pointer (handler) to a struct containing the necessary data, or a NULL in case of an error.
Parameters
config_fnameConfiguration 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:

SPR_QSPRAAK_SAMPLE_FREQ
return the required sample frequency (double)
SPR_QSPRAAK_SAMPLE_TYPE
return the required format of a sample (char*)
SPR_QSPRAAK_SAMPLE_BYTES
return the nr. of bytes per sample (int)
SPR_QSPRAAK_SAMPLE_NCHAN
return the required nr. of channels (int)
SPR_QSPRAAK_FRAME_SIZE
return the size of a frame in bytes (int)
SPR_QSPRAAK_CURR_LEX
return the currently active lexicon (char*)
SPR_QSPRAAK_CURR_LM
return the currently active LM (char*)
SPR_QSPRAAK_CURR_AM
return the currently active acoustic model (const char*)
SPR_QSPRAAK_CURR_SSP
return the currently active preprocessing (const char*)
SPR_QSPRAAK_CURR_SPKR
return the currently active speaker (const char*)
SPR_QSPRAAK_CURR_SETUP
return the currently active setup (const char*)
Returns
0 on success and -1 on failure. The requested value is written to *res.
Parameters
spraakHandler previously returned by SPRaak_init().
requestRequest type.
resLocation to store the result.