MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / normalized_codebook

Function normalized_codebook

src/models/qwen3_tts/tokenizer_speech_decoder.cpp:198–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196
197namespace {
198
199std::vector<float> normalized_codebook(
200 const assets::TensorSource & source,
201 const std::string & prefix,
202 int64_t size,
203 int64_t dim) {
204 const auto cluster_usage = source.require_f32(prefix + "cluster_usage", {size});
205 const auto embedding_sum = source.require_f32(prefix + "embedding_sum", {size, dim});
206 std::vector<float> embedding(embedding_sum.size(), 0.0F);
207 for (int64_t code = 0; code < size; ++code) {
208 const float denom = std::max(cluster_usage[static_cast<size_t>(code)], kCodebookEps);
209 for (int64_t col = 0; col < dim; ++col) {
210 const size_t offset = static_cast<size_t>(code * dim + col);
211 embedding[offset] = embedding_sum[offset] / denom;
212 }
213 }
214 return embedding;
215}
216
217DecoderConfig load_decoder_config(const Qwen3TTSAssets & assets) {

Callers 1

load_weightsFunction · 0.85

Calls 3

maxFunction · 0.85
require_f32Method · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected