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;
356 .p.priv_class = &flite_class,
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
const FFFilter ff_asrc_flite
static AVFormatContext * ctx
static int config_props(AVFilterLink *outlink)
static void list_voices(void *log_ctx, const char *sep)
#define DECLARE_REGISTER_VOICE_FN(name)
static struct voice_entry voice_entries[]
#define MAKE_VOICE_STRUCTURE(voice_name)
static int audio_stream_chunk_by_word(const cst_wave *wave, int start, int size, int last, cst_audio_streaming_info *asi)
static const AVOption flite_options[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int select_voice(struct voice_entry **entry_ret, const char *voice_name, void *log_ctx)
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static AVMutex flite_mutex
static const AVFilterPad flite_outputs[]
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
static const int sample_rates[]
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ 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...
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
int av_audio_fifo_write(AVAudioFifo *af, void *const *data, int nb_samples)
Write data to an AVAudioFifo.
int av_audio_fifo_read(AVAudioFifo *af, void *const *data, int nb_samples)
Read data from an AVAudioFifo.
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_EOF
End of file.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16
signed 16 bits
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 av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_OUTPUTS(array)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
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...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_MUTEX_INITIALIZER
Memory handling functions.
enum MovChannelLayoutTag * layouts
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
#define FF_ARRAY_ELEMS(a)
static int config_props(AVBitStreamFilterLink *link)
Context for an Audio FIFO Buffer.
An AVChannelLayout holds information about the channel layout of audio data.
Describe the class of an AVClass context structure.
A link between two filters.
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int sample_rate
samples per second
int format
agreed upon media format
A filter pad used for either input or output.
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).
int sample_rate
Sample rate of the audio data.
uint8_t ** extended_data
pointers to the data planes/channels.
Rational number (pair of numerator and denominator).
struct voice_entry * voice_entry
cst_audio_streaming_info * asi
int frame_nb_samples
number of samples per frame
void(* unregister_fn)(cst_voice *)