Prosody WAV FILE: API

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.


Prosody WAV FILE: API: sm_replay_wav_start

Prototype Definition

int sm_replay_wav_start(char *filename, SM_FILE_REPLAY_PARMS *file_parms)

Parameters

filename
The name of the WAV file to be played.
file_parms
A pointer to a structure as for sm_replay_file_start().

Description

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

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV FILE: API: sm_replay_wav_close

Prototype Definition

int sm_replay_wav_close(SM_FILE_REPLAY_PARMS *file_parms)

Parameters

file_parms
A pointer to a structure passed into sm_replay_wav_start() to start a replay that has not yet been closed.

Description

Following completion of WAV file replay this function may be called to close the replay file and release the associated file descriptor.

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV FILE: API: sm_record_wav_start

Prototype Definition

int sm_record_wav_start(char *filename, SM_FILE_RECORD_PARMS *file_parms)

Parameters

filename
The name of the file in which to put the recorded data.
file_parms
A pointer to a structure as for sm_record_file_start().

Description

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

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV FILE: API: sm_record_wav_close

Prototype Definition

int sm_record_wav_close(SM_FILE_RECORD_PARMS *file_parms)

Parameters

file_parms
A pointer to a structure passed into sm_record_wav_start() to start a record that has not yet been closed.

Description

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.

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV FILE: API: sm_record_wav_trim_close

Prototype Definition

int sm_record_wav_trim_close(SM_FILE_RECORD_PARMS *file_parms, tSM_UT32 trimLength)

Parameters

file_parms
A pointer to a structure passed into sm_record_wav_start() to start a record that has not yet been closed.
trimLength
The number of octets to trim from the end of the data.

Description

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.

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV FILE: API: sm_replay_wav_get_type

Prototype Definition

int sm_replay_wav_get_type(char *filename, int *replay_type)

Parameters

filename
The name of a WAV file.
replay_type
The address of where the data type code is to be saved.

Description

Given name of existing WAV file, returns in replay_type Prosody API data format type id that would be used by sm_replay_start().

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV FILE: API: sm_replay_wav_prepare

Prototype Definition

int sm_replay_wav_prepare(struct sm_replay_wav_prepare_parms *replay_wav_prep_parms)

Parameters

*replay_wav_prep_parms
a structure of the following type:
typedef struct sm_replay_wav_prepare_parms {
	char *filename;						/* in */
	SM_REPLAY_PARMS *replay_parms;				/* out */
} SM_REPLAY_WAV_PREPARE_PARMS;

Description

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.

Fields

filename
The name of a WAV file.
replay_parms
A structure as defined for sm_replay_start.

Returns

0 if call completed successfully, otherwise a standard error such as:


These functions constitute the Prosody WAV FILE API.