#ifndef TTS_WRAPPER_H
#define TTS_WRAPPER_H
#include <stdint.h>
#include <stdbool.h>
typedef struct tts_ctx tts_ctx;
typedef struct tts_voice {
char *id;
char *name;
char *language;
char *gender;
char *engine;
} tts_voice;
typedef void (*CAudioCb)(const uint8_t*, uintptr_t, void*);
typedef void (*CBoundaryCb)(const char*, int32_t, int32_t, float, float, int32_t, void*);
typedef void (*CMarkCb)(const char*, int32_t, float, float, void*);
typedef void (*CVisemeCb)(int32_t, float, void*);
typedef void (*CVoidCb)(void*);
typedef void (*CErrorCb)(const char*, void*);
typedef struct tts_engine_info {
char *id;
char *name;
bool needs_credentials;
char *credential_keys_json;
} tts_engine_info;
#ifdef __cplusplus
extern "C" {
#endif
struct tts_ctx *tts_create(const char *engine_id, const char *credentials_json);
void tts_destroy(struct tts_ctx *ctx);
int32_t tts_speak(struct tts_ctx *ctx, const char *text);
int32_t tts_speak_ssml(struct tts_ctx *ctx, const char *ssml);
int32_t tts_speak_sync(struct tts_ctx *ctx, const char *text);
void tts_stop(struct tts_ctx *ctx);
int32_t tts_get_voices(struct tts_ctx *ctx, struct tts_voice **out_voices, int32_t *out_count);
void tts_free_voices(struct tts_voice *voices, int32_t count);
void tts_set_voice(struct tts_ctx *ctx, const char *voice_id);
void tts_set_rate(struct tts_ctx *ctx, float rate);
void tts_set_pitch(struct tts_ctx *ctx, float pitch);
void tts_set_volume(struct tts_ctx *ctx, float volume);
void tts_set_on_audio(struct tts_ctx *ctx, CAudioCb cb, void *userdata);
void tts_set_on_boundary(struct tts_ctx *ctx, CBoundaryCb cb, void *userdata);
void tts_set_on_mark(struct tts_ctx *ctx, CMarkCb cb, void *userdata);
void tts_set_on_viseme(struct tts_ctx *ctx, CVisemeCb cb, void *userdata);
void tts_set_on_start(struct tts_ctx *ctx, CVoidCb cb, void *userdata);
void tts_set_on_end(struct tts_ctx *ctx, CVoidCb cb, void *userdata);
void tts_set_on_error(struct tts_ctx *ctx, CErrorCb cb, void *userdata);
int32_t tts_get_engine_count(void);
int32_t tts_get_engines(struct tts_engine_info **out_engines, int32_t *out_count);
void tts_free_engines(struct tts_engine_info *engines, int32_t count);
const char *tts_get_last_error(struct tts_ctx *ctx);
void tts_pause(struct tts_ctx *ctx);
void tts_resume(struct tts_ctx *ctx);
int32_t tts_synth_to_bytes(struct tts_ctx *ctx,
const char *text,
uint8_t **out_bytes,
uintptr_t *out_len);
void tts_free_bytes(uint8_t *bytes, uintptr_t len);
extern void *avsynth_create(void);
extern void avsynth_destroy(void *handle);
extern void avsynth_speak(void *handle,
const char *text,
const char *voice_id,
float rate,
float pitch,
float volume);
extern void avsynth_stop(void *handle);
extern void avsynth_pause(void *handle);
extern void avsynth_resume(void *handle);
extern int32_t avsynth_voice_count(void *handle);
extern int32_t avsynth_get_voice(void *handle,
int32_t index,
char *id_buf,
int32_t id_buf_len,
char *name_buf,
int32_t name_buf_len,
char *lang_buf,
int32_t lang_buf_len);
#ifdef __cplusplus
} #endif
#endif