plugin/fvin.c File Reference

A skeleton code of feature input plugin. More...

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


Detailed Description

A skeleton code of feature input plugin.

Author:
Akinobu Lee
Date:
Mon Aug 11 17:05:17 2008
Revision
1.1

Definition in file fvin.c.


Define Documentation

#define PLUGIN_TITLE   "Feature vector input plugin for Julius"

feature input plugin functions

Required:

Optional:

Definition at line 50 of file fvin.c.


Function Documentation

int initialize (  ) 

Initialization at loading time (optional).

If defined, this will be called just before this plugin is loaded to Julius. if this returns -1, the whole functions in this file will not be loaded.

This function is OPTIONAL.

Returns:
0 on success, -1 on failure.

Definition at line 78 of file fvin.c.

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

Parameters:
opcode [in] requested operation code
buf [out] buffer to store the return string
buflen [in] maximum length of buf
Returns:
0 on success, -1 on failure. On failure, Julius will ignore this plugin.

Definition at line 120 of file fvin.c.

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.

Parameters:
buf [out] buffer to store the return string
buflen [in] maximum length of buf

Definition at line 165 of file fvin.c.

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.

Parameters:
opcode [in] requested operation code
Returns:
values required for the opcode as described.

Definition at line 212 of file fvin.c.

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

Returns:
TRUE on success, FALSE on failure.

Definition at line 254 of file fvin.c.

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

Returns:
TRUE on success, FALSE on failure.

Definition at line 289 of file fvin.c.

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.

Parameters:
vecbuf [out] store a vector obtained in this function
veclen [in] vector length
Returns:
0 on success, ADIN_EOF on end of stream, ADIN_SEGMENT to request segmentation to Julius, or ADIN_ERROR on error.

Definition at line 346 of file fvin.c.

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

Returns:
TRUE on success, FALSE on failure.

Definition at line 390 of file fvin.c.

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.

Returns:
TRUE on success, FALSE on failure.

Definition at line 443 of file fvin.c.

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.

Returns:
TRUE on success, FALSE on failure.

Definition at line 499 of file fvin.c.

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.

Returns:
TRUE on success, FALSE on failure.

Definition at line 546 of file fvin.c.


Generated on Thu Jul 23 12:14:20 2009 for Julius by  doxygen 1.5.1