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

Function l2_normalize

src/models/chatterbox/voice_encoder_impl.cpp:27–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27std::vector<float> l2_normalize(const std::vector<float> & values) {
28 float norm_sq = 0.0f;
29 for (float value : values) {
30 norm_sq += value * value;
31 }
32 const float norm = std::sqrt(std::max(norm_sq, 1.0e-12f));
33 std::vector<float> out(values.size(), 0.0f);
34 for (size_t i = 0; i < values.size(); ++i) {
35 out[i] = values[i] / norm;
36 }
37 return out;
38}
39
40std::vector<float> resample_voice_encoder_mono(
41 const std::vector<float> & input,

Callers 2

project_embeddingFunction · 0.85

Calls 2

maxFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected