#pragma once
#include "ggml.h"
#include "transcribe.h"
#include <cstdint>
#include <string>
#include <vector>
namespace transcribe::bin_loader {
inline constexpr uint32_t k_whisper_bin_magic = 0x67676d6cu;
struct WhisperBinHParams {
int32_t n_vocab = 0;
int32_t n_audio_ctx = 0;
int32_t n_audio_state = 0;
int32_t n_audio_head = 0;
int32_t n_audio_layer = 0;
int32_t n_text_ctx = 0;
int32_t n_text_state = 0;
int32_t n_text_head = 0;
int32_t n_text_layer = 0;
int32_t n_mels = 0;
int32_t ftype = 0; };
struct BinTensorEntry {
std::string name; ggml_type type = GGML_TYPE_F32;
int32_t n_dims = 0;
int64_t ne[4] = { 1, 1, 1, 1 }; uint64_t offset = 0;
uint64_t nbytes = 0;
};
struct WhisperBinModel {
std::string path;
WhisperBinHParams hp;
bool is_multilingual = false;
int32_t num_languages = 0;
int32_t n_mel_filters = 0; int32_t n_fft_filters = 0; std::vector<float> mel_filterbank;
std::vector<std::string> vocab_tokens;
std::vector<BinTensorEntry> tensors;
};
transcribe_status parse_whisper_bin(const char * path, WhisperBinModel & out);
struct BinStreamSlot {
ggml_tensor * dst = nullptr;
uint64_t src_off = 0;
uint64_t src_bytes = 0;
};
transcribe_status stream_tensor_data_from_bin(const std::string & path,
const std::vector<BinStreamSlot> & slots,
const char * error_tag);
}