You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.3 KiB
54 lines
2.3 KiB
/* |
|
* chat_whisper.h — Whisper speech-to-text транскрипция для голосовых сообщений |
|
* |
|
* Интеграция с whisper.cpp C API (libwhisper): |
|
* - Детекция доступности whisper в системе |
|
* - Ленивая загрузка модели при первом голосовом сообщении |
|
* - Асинхронная транскрипция через media_async (thread-per-task) |
|
* - Сериализация: одна транскрипция за раз (whisper не thread-safe) |
|
* - Авто-поиск модели: настройка → ~/.local/share/utun/models/ → /usr/share/utun/models/ |
|
* |
|
* chat_msg.c вызывает транскрипцию через глобальный function pointer |
|
* g_chat_whisper_trigger, который устанавливается при инициализации whisper. |
|
* Если whisper не скомпилирован/недоступен — pointer = NULL, вызов игнорируется. |
|
*/ |
|
#ifndef CHAT_WHISPER_H |
|
#define CHAT_WHISPER_H |
|
|
|
#include <stdint.h> |
|
#include <stddef.h> |
|
|
|
#ifdef __cplusplus |
|
extern "C" { |
|
#endif |
|
|
|
struct media_async; |
|
struct UASYNC; |
|
struct UTUN_INSTANCE; |
|
|
|
/* ── жизненный цикл ── */ |
|
|
|
int chat_whisper_init(struct UTUN_INSTANCE* inst); /* ленивая загрузка модели */ |
|
int chat_whisper_available(struct UTUN_INSTANCE* inst); /* модель загружена и готова */ |
|
void chat_whisper_destroy(void); /* выгрузка модели */ |
|
|
|
/* ── асинхронная транскрипция ── */ |
|
|
|
typedef void (*chat_whisper_done_fn)(void* arg, const char* channel_id, |
|
const char* text, int err, |
|
uint64_t reply_ts, uint64_t reply_node); |
|
|
|
typedef void (*chat_whisper_trigger_fn)( |
|
struct UTUN_INSTANCE* inst, |
|
struct media_async* ma, struct UASYNC* ua, |
|
const char* audio_path, const char* channel_id, |
|
uint64_t reply_ts, uint64_t reply_node, |
|
chat_whisper_done_fn done_cb, void* done_arg); |
|
|
|
/* Глобальный триггер: устанавливается chat_whisper_init(), вызывается из chat_msg.c */ |
|
extern chat_whisper_trigger_fn g_chat_whisper_trigger; |
|
|
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
#endif /* CHAT_WHISPER_H */
|
|
|