#include <stdio.h>
#include <string.h>
#include "plugin_defs.h"
Go to the source code of this file.
Defines | |
#define | PLUGIN_TITLE "Feature vector input plugin for Julius" |
feature input plugin functions | |
#define | INPUT_OPT "myfvin" |
Functions | |
int | initialize () |
Initialization at loading time (optional). | |
int | get_plugin_info (int opcode, char *buf, int buflen) |
Get information of this plugin (required). | |
void | fvin_get_optname (char *buf, int buflen) |
Return option string to select this input at option. | |
int | fvin_get_configuration (int opcode) |
Return configuration parameters for this input (required). | |
boolean | fvin_standby () |
Initialize input device (required). | |
boolean | fvin_open () |
Open an input (required). | |
int | fvin_read (float *vecbuf, int veclen) |
Read a vector from input (required). | |
boolean | fvin_close () |
Close the current input (required). | |
boolean | fvin_terminate () |
A hook for Termination request (optional). | |
boolean | fvin_pause () |
A hook for Pause request (optional). | |
boolean | fvin_resume () |
A hook for Resume request (optional). |
Definition in file fvin.c.
#define PLUGIN_TITLE "Feature vector input plugin for Julius" |
feature input plugin functions
Required:
Optional:
int initialize | ( | ) |
int get_plugin_info | ( | int | opcode, | |
char * | buf, | |||
int | buflen | |||
) |
Get information of this plugin (required).
This function should return informations of this plugin file. The required info will be specified by opcode:
This will be called just after Julius find this file and after initialize().
opcode | [in] requested operation code | |
buf | [out] buffer to store the return string | |
buflen | [in] maximum length of buf |
void fvin_get_optname | ( | char * | buf, | |
int | buflen | |||
) |
Return option string to select this input at option.
(required)
This function should return option string which should be specified as an argument "-input" option, to be used on Julius. The returning string should not be the same with any existing value.
This function will be called several times at option parsing at startup.
buf | [out] buffer to store the return string | |
buflen | [in] maximum length of buf |
int fvin_get_configuration | ( | int | opcode | ) |
Return configuration parameters for this input (required).
This function should return configuration parameters about the input.
When opcode = 0, return the dimension (length) of input vector.
When opcode = 1, return the frame interval (time between frames) in milliseconds.
When opcode = 2, parameter type code can be returned. The code should the same format as used in HTK parameter file header. This is for checking the input parameter type against acousitc model, and you can disable the checking by returning "0xffff" to this opcode.
opcode | [in] requested operation code |
boolean fvin_standby | ( | ) |
Initialize input device (required).
This will be called only once at start up of Julius. You can check if the input file exists or prepare a socket for connection.
If this function returns FALSE, Julius will exit.
JuliusLib: this function will be called at j_adin_init().
boolean fvin_open | ( | ) |
Open an input (required).
This function should open a new input. You may open a feature vector file, or wait for connection at this function.
If this function returns FALSE, Julius will exit recognition loop.
JuliusLib: this will be called at j_open_stream().
int fvin_read | ( | float * | vecbuf, | |
int | veclen | |||
) |
Read a vector from input (required).
This will be called repeatedly at each frame, and the read vector will be processed immediately, and then this function is called again.
Return value of ADIN_EOF tells end of stream to Julius, which causes Julius to finish current recognition and close stream. ADIN_SEGMENT requests Julius to segment the current input. The current recognition will be stopped at this point, recognition result will be output, and then Julius continues to the next input. The behavior of ADIN_SEGMENT is similar to ADIN_EOF except that ADIN_SEGMENT does not close/open input, but just stop and restart the recognition. At last, return value should be ADIN_ERROR on error, in which Julius exits itself immediately.
vecbuf | [out] store a vector obtained in this function | |
veclen | [in] vector length |
boolean fvin_close | ( | ) |
Close the current input (required).
This function will be called when the input has reached end of file (i.e. the last call of fvin_read() returns ADIN_EOF)
You may close a file or disconnect network client here.
If this function returns TRUE, Julius will go again to adin_open() to open another stream. If returns FALSE, Julius will exit the recognition loop.
JuliusLib: This will be called at the end of j_recognize_stream().
boolean fvin_terminate | ( | ) |
A hook for Termination request (optional).
This function will be called when Julius receives a Termination request to stop running. This can be used to synchronize input facility with Julius's running status.
Termination will occur when Julius is running on module mode and received TERMINATE command from client, or j_request_terminate() is called inside application. On termination, Julius will stop recognition immediately (discard current input if in process), and wait until received RESUME command or call of j_request_resume().
This hook function will be called just after a Termination request. Please note that this will be called when Julius receives request, not on actual termination.
boolean fvin_pause | ( | ) |
A hook for Pause request (optional).
This function will be called when Julius receives a Pause request to stop running. This can be used to synchronize input facility with Julius's running status.
Pause will occur when Julius is running on module mode and received PAUSE command from client, or j_request_pause() is called inside application. On pausing, Julius will stop recognition and then wait until it receives RESUME command or j_request_resume() is called. When pausing occurs while recognition is running, Julius will process it to the end before stops.
This hook function will be called just after a Pause request. Please note that this will be called when Julius receives request, not on actual pause.
boolean fvin_resume | ( | ) |
A hook for Resume request (optional).
This function will be called when Julius received a resume request to recover from pause/termination status.
Resume will occur when Julius has been stopped by receiving RESUME command from client on module mode, or j_request_resume() is called inside application.
This hook function will be called just after a resume request. This can be used to make this A/D-in plugin cooperate with the pause/resume status, for example to tell audio client to restart audio streaming.
This function is totally optional.