#pragma once
#include "transcribe.h"
#include <cstdint>
#include <string>
#include <vector>
struct gguf_context;
struct ggml_context;
struct ggml_tensor;
namespace transcribe::sensevoice {
struct SenseVoiceHParams {
int32_t enc_n_blocks = 0; int32_t enc_tp_blocks = 0;
int32_t enc_d_model = 0; int32_t enc_d_input = 0; int32_t enc_n_heads = 0; int32_t enc_d_ff = 0; int32_t enc_kernel = 0; int32_t enc_sanm_shift = 0; std::string enc_attn_type; bool enc_normalize_before = true;
int32_t vocab_size = 0;
std::string fe_type; int32_t fe_num_mels = 0; int32_t fe_sample_rate = 0; int32_t fe_n_fft = 0; int32_t fe_win_length = 0; int32_t fe_hop_length = 0; std::string fe_window; std::string fe_normalize; std::string fe_fbank_style; float fe_dither = 0.0f;
bool fe_upscale_samples = true;
bool fe_snip_edges = true;
int32_t fe_lfr_m = 0; int32_t fe_lfr_n = 0;
int32_t prefix_lang_auto = 0;
int32_t prefix_lang_zh = 0;
int32_t prefix_lang_en = 0;
int32_t prefix_lang_yue = 0;
int32_t prefix_lang_ja = 0;
int32_t prefix_lang_ko = 0;
int32_t prefix_lang_nospeech = 0;
int32_t prefix_event_speech = 0;
int32_t prefix_emotion_neutral = 0;
int32_t prefix_withitn = 0;
int32_t prefix_woitn = 0;
int32_t enc_head_dim() const { return enc_n_heads > 0 ? enc_d_model / enc_n_heads : 0; }
};
transcribe_status read_sensevoice_hparams(const gguf_context * gguf, SenseVoiceHParams & hp);
struct SenseVoiceBlock {
ggml_tensor * norm_attn_w = nullptr; ggml_tensor * norm_attn_b = nullptr; ggml_tensor * attn_qkv_w = nullptr; ggml_tensor * attn_qkv_b = nullptr; ggml_tensor * attn_out_w = nullptr; ggml_tensor * attn_out_b = nullptr; ggml_tensor * attn_fsmn_w = nullptr; ggml_tensor * norm_ffn_w = nullptr; ggml_tensor * norm_ffn_b = nullptr; ggml_tensor * ffn_fc1_w = nullptr; ggml_tensor * ffn_fc1_b = nullptr; ggml_tensor * ffn_fc2_w = nullptr; ggml_tensor * ffn_fc2_b = nullptr; };
struct SenseVoiceWeights {
ggml_tensor * cmvn_shift = nullptr; ggml_tensor * cmvn_scale = nullptr;
ggml_tensor * embed = nullptr;
SenseVoiceBlock encoders0;
std::vector<SenseVoiceBlock> encoders;
ggml_tensor * after_norm_w = nullptr; ggml_tensor * after_norm_b = nullptr;
std::vector<SenseVoiceBlock> tp_encoders;
ggml_tensor * tp_norm_w = nullptr; ggml_tensor * tp_norm_b = nullptr;
ggml_tensor * ctc_head_w = nullptr; ggml_tensor * ctc_head_b = nullptr; };
transcribe_status build_sensevoice_weights(ggml_context * ctx_meta,
const SenseVoiceHParams & hp,
SenseVoiceWeights & weights);
}