The following functions are provided by the Prosody high level BFILE play/record API:
API call | W | Description |
---|---|---|
sm_replay_bfile_start() | Start replaying data from a file. | |
sm_replay_bfile_progress_istatus() | Proceed with replaying data from a file | |
sm_replay_bfile_progress() | Proceed with replaying data from a file | |
sm_replay_bfile_complete() | Replay remaining data from a file and clean up afterwards | |
sm_replay_bfile_stop() | Abort replaying data from a file. | |
sm_record_bfile_start() | Start recording data into a file. | |
sm_record_bfile_progress_istatus() | Proceed with recording data to a file | |
sm_record_bfile_progress_ostatus() | Proceed with recording data to a file and report ongoing status | |
sm_record_bfile_progress() | Proceed with recording data to a file | |
sm_record_bfile_complete() | Record remaining data to a file and clean up afterwards | |
sm_record_bfile_complete_tstatus() | T | Record remaining data to a file, report temination status and clean up afterwards |
sm_record_bfile_stop() | Abort the recording of data to a file |
Key to W column:
T | Functionality added in Prosody version 2 (TiNG) |
---|
This document is also available as separate pages for each function.
int sm_replay_bfile_start(struct sm_bfile_replay_parms *file_parms)
typedef struct sm_bfile_replay_parms { BFILE *fd; /* in */ tSM_UT32 offset; /* in */ SM_REPLAY_PARMS replay_parms; /* in */ int status; /* out */ tSM_UT32 private_length; /* out */ int completing; /* out */ int data_length_in_buffer; /* out */ char buffer[kSMMaxHBReplayDataBufferSize]; /* out */ } SM_BFILE_REPLAY_PARMS;
Prepares a channel for replay of data from a file to an output channel previously allocated by a call to sm_channel_alloc_placed().
The fields of the structure replay_parms should be set up as described in sm_replay_start() low level API call. Note the field data_length should either be set to zero or to the actual number of octets to be replayed from the file. If it is set to zero then all of the data starting from offset to the end of the file will be replayed.
The
status
field is used to indicate the current status of the
replay. On return from a successful invocation of
sm_replay_bfile_start()
it will be set to a value of ERR_SM_PENDING
and
will continue to have this value until replay has been
completed, aborted or terminated on occurrence of an error.
The fields private_length, data_length_in_buffer and buffer are used internally by the high level library and should not be accessed by the application.
The replay is finished when a call to sm_replay_bfile_complete() returns.
0 if call completed successfully, otherwise a standard error such as:
int sm_replay_bfile_progress_istatus(SM_BFILE_REPLAY_PARMS *file_parms, int initial_status)
Transfers file data to speech processing module for previously initiated replay unless the channel has insufficient buffering space to accept more data, or all data has been transferred, or an error occurs.
If the current replay status for the channel is not known, then the sm_replay_bfile_progress() variant of the call must be used.
The parameter
file_parms
must point to the same
sm_bfile_replay_parms
structure as was previously
used to initiate the file replay.
On return if the status field is still set to a value of
ERR_SM_PENDING
then further calls to this routine will be
required to complete the file replay. If status has a zero value
then replay has successfully completed. Otherwise replay has
been terminated on error, and status will be set to a
corresponding error code.
Note: this routine must be periodically invoked following a call to sm_replay_bfile_start(). This may either be done explicitly by the application, or alternatively through a call to sm_replay_bfile_complete() which will handle the scheduling of calls to sm_replay_bfile_progress() on behalf of the application.
The same value as stored in the status field of the structure
pointed to by
file_parms
which is 0 or ERR_SM_PENDING
if call completed successfully, otherwise a standard error such as:
int sm_replay_bfile_progress(SM_BFILE_REPLAY_PARMS *file_parms)
This is the same as sm_replay_bfile_progress_istatus() except it first determines the replay status.
If the current replay status for the channel is known, then the sm_replay_bfile_progress_istatus() variant of the call should be used with initial_status set to this status.
int sm_replay_bfile_complete(SM_BFILE_REPLAY_PARMS *file_parms)
Transfers all remaining data from file to speech processing module for previously initiated replay. This call may block during execution while it waits for buffering capacity to become available on the speech processing module.
On completion the offset field will have been updated to indicate at which byte offset in the file replay was aborted at, thus allowing a simple method for playback to be resumed through a subsequent call to sm_replay_bfile_start().
Note that this function assigns an event to the channel and removes it again when the replay finishes. If the channel previously had an event assigned, that assignment may have been lost (this depends on the operating system as events work differently on different operating systems).
0 if call completed successfully, otherwise a standard error such as:
int sm_replay_bfile_stop(SM_BFILE_REPLAY_PARMS *file_parms, int nowait)
Abort a previously initiated file replay. If nowait if non-zero, this function assumes the current file replay is being progressed by a separate thread of execution in which sm_replay_bfile_complete() has been invoked.
0 if call completed successfully, otherwise a standard error such as:
int sm_record_bfile_start(struct sm_bfile_record_parms *file_parms)
typedef struct sm_bfile_record_parms { BFILE *fd; /* in */ SM_RECORD_PARMS record_parms; /* in */ int status; /* out */ tSM_UT32 private_length; /* out */ int completing; /* out */ char buffer[kSMMaxHBRecordDataBufferSize]; /* out */ } SM_BFILE_RECORD_PARMS;
Prepares channel for recording of data to a file from an input channel previously allocated by a call to sm_channel_alloc_placed().
The status field is used to indicate the current status of the
record. On return from a successful invocation of
sm_record_bfile_start()
it will be set to a value of ERR_SM_PENDING
and
will continue to have this value until recording has been
completed, aborted or terminated on occurrence of an error.
The fields private_length and buffer are used internally by the high level library and should not be accessed by the application.
The recording is finished when a call to sm_record_bfile_complete() returns.
0 if call completed successfully, otherwise a standard error such as:
int sm_record_bfile_progress_istatus(SM_BFILE_RECORD_PARMS *file_parms, int initial_status)
Transfers data from a recording channel to file for a previously initiated record unless the channel has insufficient buffered data to collect, or all data in recording has been collected, or an error occurs.
If the current record status for the channel is not known, then the sm_record_bfile_progress() variant of the call must be used.
On return if the status field is still set to a value of
ERR_SM_PENDING
then further calls to this routine
will be required to complete the file record. Otherwise the
recording has finished. If the status is zero then
recording has been successful, if it is non-zero, the record has
been terminated on error, and the status will be set to a
corresponding error code. In either case,
sm_record_bfile_complete()
must be called to clean up after the recording.
Note: this routine must be periodically invoked following a call to sm_record_bfile_start(). This may either be done explicitly by the application, or alternatively through a call to sm_record_bfile_complete() which will handle the scheduling of calls to sm_record_bfile_progress() on behalf of the application.
Note that the sampling_rate of the record_parms structure is not updated to the recorded sample rate, as returned by sm_record_status(). If the recording is to a WAV file, then this is must be done by the application before closing the WAV file. Otherwise the WAV header will not have the correct values.
The same value as stored in the status field of the structure
pointed to by
file_parms
which is 0 or ERR_SM_PENDING
if call completed successfully, otherwise a standard error such as:
int sm_record_bfile_progress_ostatus(SM_BFILE_RECORD_PARMS *file_parms, SM_RECORD_STATUS_PARMS *status_parms)
This is the same as sm_record_file_progress_istatus() except it first determines the status of the recording and reports this to the user.
When this function returns without an error, the fields in the status_parms structure are valid. On completion of a recording, the termination status will be reported in the status_parms structure.
If the current record status for the channel is known, then the sm_record_file_progress_istatus() variant of the call should be used with initial_status set to this status.
The same value as stored in the status field of the structure
pointed to by
file_parms
which is 0 or ERR_SM_PENDING
if call completed successfully, otherwise a standard error such as:
int sm_record_bfile_progress(SM_BFILE_RECORD_PARMS *file_parms)
This is the same as sm_record_bfile_progress_istatus() except it first determines the record status.
If the current record status for the channel is known, then the sm_record_bfile_progress_istatus() variant of the call should be used with initial_status set to this status.
The same value as stored in the status field of the structure
pointed to by
file_parms
which is 0 or ERR_SM_PENDING
if call completed successfully, otherwise a standard error such as:
int sm_record_bfile_complete(SM_BFILE_RECORD_PARMS *file_parms)
Transfers all remaining data from speech processing module to file for previously initiated record. This call may block during execution while it waits for buffered data to become available on the speech processing module.
Note that this function assigns an event to the channel and removes it again when the replay finishes. If the channel previously had an event assigned, that assignment may have been lost (this depends on the operating system as events work differently on different operating systems).
0 if call completed successfully, otherwise a standard error such as:
This function is only in Prosody version 2 (TiNG).
int sm_record_bfile_complete_tstatus(SM_BFILE_RECORD_PARMS *file_parms, SM_RECORD_STATUS_PARMS *status_parms)
This is the same as sm_record_bfile_complete() except that on successful completion the status_parms structure will contain the termination status of the recording. The fields in the status_parms structure are only valid when the function returns success.
0 if call completed successfully, otherwise a standard error such as:
int sm_record_bfile_stop(SM_BFILE_RECORD_PARMS *file_parms, int nowait)
Abort a previously initiated file recording. If nowait if non-zero, this function assumes the current file recording is being progressed by a separate thread of execution in which sm_record_bfile_complete() has been invoked.
0 if call completed successfully, otherwise a standard error such as:
These functions constitute the Prosody high level BFILE play/record API.