The following functions are provided by the Prosody WAV FILE API:
API call | W | Description |
---|---|---|
sm_replay_wav_start() | Play a WAV file | |
sm_replay_wav_close() | Close a WAV file opened by sm_replay_wav_start | |
sm_record_wav_start() | Record into a WAV file | |
sm_record_wav_close() | Close a WAV file created by sm_record_wav_start | |
sm_record_wav_trim_close() | Trim and close a WAV file created by sm_record_wav_start | |
sm_replay_wav_get_type() | Determine the type of data in a WAV file | |
sm_replay_wav_prepare() | Prepare for replay based on description in WAV file |
This document is also available as separate pages for each function.
int sm_replay_wav_start(char *filename, SM_FILE_REPLAY_PARMS *file_parms)
Opens and parses the header of WAV file, sets up fd, replay_parms.type, replay_parms.sampling_rate, and replay_parms.data_length, in structure pointed at by file_parms and then invokes sm_replay_file_start().
The other elements of the replay_parms structure must be set up as for sm_replay_file_start(). Note that the offset is assumed to be relative to the first octet of audio data following the WAV header. If offset, and replay_parms.data_length, are both set to zero then file_parms will be set up to replay all the speech data in the WAV file.
Note: It is the responsibility of the application to operate the replay as described in Prosody high level FILE play/record documentation and to close the file following replay completion or abort (using sm_replay_wav_close()).
0 if call completed successfully, otherwise a standard error such as:
int sm_replay_wav_close(SM_FILE_REPLAY_PARMS *file_parms)
Following completion of WAV file replay this function may be called to close the replay file and release the associated file descriptor.
0 if call completed successfully, otherwise a standard error such as:
int sm_record_wav_start(char *filename, SM_FILE_RECORD_PARMS *file_parms)
Creates a file with the given name, allocates space in the file by writing blank WAV file header, sets up fd in structure pointed at by file_parms and then invokes sm_record_file_start().
The other elements of the record_parms. structure must be set up as for sm_record_file_start(). The setting of the record_parms.type, parameter will determine type of WAV file created.
Note it is the responsibility of the application to close the file following record completion or abort using sm_record_wav_close().
0 if call completed successfully, otherwise a standard error such as:
int sm_record_wav_close(SM_FILE_RECORD_PARMS *file_parms)
Following completion of a recording into a WAV file this function must be called to write the correct WAV header in space previously reserved by sm_record_wav_start() then closes the file.
Note that the sampling_rate of the record_parms structure must be set to the recorded sample rate,as returned by sm_record_status(). This is done automatically except when sm_record_file_progress_istatus() has been used.
0 if call completed successfully, otherwise a standard error such as:
int sm_record_wav_trim_close(SM_FILE_RECORD_PARMS *file_parms, tSM_UT32 trimLength)
trimLength octets of data are subtracted from the WAV file length recorded in the WAV header and hence this amount of data will be omitted from the end of a replay of this WAV file. Then a sm_record_wav_close() is performed.
Note that the sampling_rate of the record_parms structure must be set to the recorded sample rate,as returned by sm_record_status(). This is done automatically except when sm_record_file_progress_istatus() has been used.
0 if call completed successfully, otherwise a standard error such as:
int sm_replay_wav_get_type(char *filename, int *replay_type)
Given name of existing WAV file, returns in replay_type Prosody API data format type id that would be used by sm_replay_start().
0 if call completed successfully, otherwise a standard error such as:
int sm_replay_wav_prepare(struct sm_replay_wav_prepare_parms *replay_wav_prep_parms)
typedef struct sm_replay_wav_prepare_parms { char *filename; /* in */ SM_REPLAY_PARMS *replay_parms; /* out */ } SM_REPLAY_WAV_PREPARE_PARMS;
Given an open WAV file, populates the replay_parms structure with the information required to start a replay. The channel field will remain uninitialised until a valid tSMChannelId is supplied. Please note that the replay_parms structure must have already been cleared (usually with memset()) before calling this function. After this function returnes you may modify the field in that structure before starting a replay.
0 if call completed successfully, otherwise a standard error such as:
These functions constitute the Prosody WAV FILE API.