#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*, float, float, 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_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);
int32_t tts_get_engine_count(void);
void tts_get_engines(struct tts_engine_info *out_engines);
void tts_free_engine_info(struct tts_engine_info *engines, int32_t count);
const char *tts_get_last_error(void);
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);
#ifdef __cplusplus
} #endif
#endif