#ifndef _APRIL_API
#define _APRIL_API
#include <stddef.h>
#include <stdint.h>
#ifdef _APRIL_EXPORT
#if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__)
#define APRIL_EXPORT __declspec(dllexport)
#else
#define APRIL_EXPORT __attribute__((visibility("default")))
#endif
#else
#if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__)
#ifdef APRIL_DLL_IMPORT
#define APRIL_EXPORT __declspec(dllimport)
#else
#define APRIL_EXPORT
#endif
#else
#define APRIL_EXPORT
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct AprilASRModel_i;
struct AprilASRSession_i;
typedef struct AprilASRModel_i * AprilASRModel;
typedef struct AprilASRSession_i * AprilASRSession;
#define APRIL_VERSION 1
APRIL_EXPORT void aam_api_init(int version);
APRIL_EXPORT AprilASRModel aam_create_model(const char *model_path);
APRIL_EXPORT const char *aam_get_name(AprilASRModel model);
APRIL_EXPORT const char *aam_get_description(AprilASRModel model);
APRIL_EXPORT const char *aam_get_language(AprilASRModel model);
APRIL_EXPORT size_t aam_get_sample_rate(AprilASRModel model);
APRIL_EXPORT void aam_free(AprilASRModel model);
typedef struct AprilSpeakerID {
uint8_t data[16];
} AprilSpeakerID;
typedef enum AprilResultType {
APRIL_RESULT_UNKNOWN = 0,
APRIL_RESULT_RECOGNITION_PARTIAL,
APRIL_RESULT_RECOGNITION_FINAL,
APRIL_RESULT_ERROR_CANT_KEEP_UP,
APRIL_RESULT_SILENCE
} AprilResultType;
typedef enum AprilTokenFlagBits {
APRIL_TOKEN_FLAG_WORD_BOUNDARY_BIT = 0x00000001,
APRIL_TOKEN_FLAG_SENTENCE_END_BIT = 0x00000002
} AprilTokenFlagBits;
typedef struct AprilToken {
const char *token;
float logprob;
AprilTokenFlagBits flags;
size_t time_ms;
void *reserved;
} AprilToken;
typedef void(*AprilRecognitionResultHandler)(void*, AprilResultType, size_t, const AprilToken*);
typedef enum AprilConfigFlagBits {
APRIL_CONFIG_FLAG_ZERO_BIT = 0x00000000,
APRIL_CONFIG_FLAG_ASYNC_RT_BIT = 0x00000001,
APRIL_CONFIG_FLAG_ASYNC_NO_RT_BIT = 0x00000002,
} AprilConfigFlagBits;
typedef struct AprilConfig {
AprilSpeakerID speaker;
AprilRecognitionResultHandler handler;
void *userdata;
AprilConfigFlagBits flags;
} AprilConfig;
APRIL_EXPORT AprilASRSession aas_create_session(AprilASRModel model, AprilConfig config);
APRIL_EXPORT void aas_feed_pcm16(AprilASRSession session, short *pcm16, size_t short_count);
APRIL_EXPORT void aas_flush(AprilASRSession session);
APRIL_EXPORT float aas_realtime_get_speedup(AprilASRSession session);
APRIL_EXPORT void aas_free(AprilASRSession session);
#ifdef __cplusplus
}
#endif
#endif