Go to the documentation of this file.
26 #include <flite/flite.h>
51 cst_audio_streaming_info *
asi;
57 #define OFFSET(x) offsetof(FliteContext, x)
58 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
78 #define DECLARE_REGISTER_VOICE_FN(name) \
79 cst_voice *register_cmu_us_## name(const char *); \
80 void unregister_cmu_us_## name(cst_voice *)
89 cst_voice * (*register_fn)(
const char *);
95 #define MAKE_VOICE_STRUCTURE(voice_name) { \
96 .name = #voice_name, \
97 .register_fn = register_cmu_us_ ## voice_name, \
98 .unregister_fn = unregister_cmu_us_ ## voice_name, \
111 for (
i = 0;
i < n;
i++)
122 if (!strcmp(
entry->name, voice_name)) {
129 entry->usage_count++;
133 "Could not register voice '%s'\n", voice_name);
149 int last, cst_audio_streaming_info *asi)
152 void *
const ptr[8] = { &wave->samples[start] };
159 return CST_AUDIO_STREAM_STOP;
164 return CST_AUDIO_STREAM_CONT;
180 if ((
ret = flite_init()) >= 0)
195 "Both text and textfile options set: only one must be specified\n");
205 "The text file '%s' could not be read: %s\n",
214 memcpy(flite->
text, textbuf, textbuf_size);
215 flite->
text[textbuf_size] = 0;
221 "No speech text specified, specify the 'text' or 'textfile' option\n");
225 flite->
asi = new_audio_streaming_info();
230 flite->
asi->userdata = flite;
231 feat_set(flite->
voice->features,
"streaming_info", audio_streaming_info_val(flite->
asi));
238 flite_text_to_speech(text, flite->
voice,
"none");
270 { .nb_channels = 0 },
326 flite_text_to_speech(text, flite->
voice,
"none");
338 samplesref->
pts = flite->
pts;
340 flite->
pts += nb_samples;
363 .priv_class = &flite_class,
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
const AVFilter ff_asrc_flite
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static const AVOption flite_options[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
enum MovChannelLayoutTag * layouts
#define AVERROR_EOF
End of file.
int av_audio_fifo_write(AVAudioFifo *af, void *const *data, int nb_samples)
Write data to an AVAudioFifo.
static const int sample_rates[]
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_LOG_VERBOSE
Detailed information.
const char * name
Filter name.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
struct voice_entry * voice_entry
A link between two filters.
AVFILTER_DEFINE_CLASS(flite)
#define MAKE_VOICE_STRUCTURE(voice_name)
static AVMutex flite_mutex
Context for an Audio FIFO Buffer.
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int log_offset, void *log_ctx)
Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap...
static int activate(AVFilterContext *ctx)
cst_audio_streaming_info * asi
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
static void list_voices(void *log_ctx, const char *sep)
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
#define FILTER_OUTPUTS(array)
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
Describe the class of an AVClass context structure.
static const AVFilterPad flite_outputs[]
static struct voice_entry voice_entries[]
Rational number (pair of numerator and denominator).
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
#define pthread_mutex_unlock(a)
void(* unregister_fn)(cst_voice *)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int sample_rate
Sample rate of the audio data.
int format
agreed upon media format
static int audio_stream_chunk_by_word(const cst_wave *wave, int start, int size, int last, cst_audio_streaming_info *asi)
#define AV_MUTEX_INITIALIZER
int av_audio_fifo_read(AVAudioFifo *af, void *const *data, int nb_samples)
Read data from an AVAudioFifo.
AVFilterContext * src
source filter
#define AVERROR_EXTERNAL
Generic error in an external library.
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
static int config_props(AVFilterLink *outlink)
#define AV_LOG_INFO
Standard information.
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int sample_rate
samples per second
#define i(width, name, range_min, range_max)
uint8_t ** extended_data
pointers to the data planes/channels.
AVSampleFormat
Audio sample formats.
#define FILTER_QUERY_FUNC2(func)
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Pad name.
static av_cold void uninit(AVFilterContext *ctx)
@ AV_OPT_TYPE_INT
Underlying C type is int.
static av_cold int init(AVFilterContext *ctx)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
#define DECLARE_REGISTER_VOICE_FN(name)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static int select_voice(struct voice_entry **entry_ret, const char *voice_name, void *log_ctx)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
int frame_nb_samples
number of samples per frame
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
#define pthread_mutex_lock(a)