MCPcopy Create free account
hub / github.com/cactus-compute/cactus / test_audio_embeddings

Function test_audio_embeddings

tests/test_embed.cpp:84–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84static bool test_audio_embeddings() {
85 std::cout << "\n╔══════════════════════════════════════════╗\n"
86 << "║ AUDIO EMBEDDING TEST ║\n"
87 << "╚══════════════════════════════════════════╝\n";
88
89 if (!g_transcribe_model_path) {
90 std::cout << "⊘ SKIP │ CACTUS_TEST_TRANSCRIBE_MODEL not set\n";
91 return true;
92 }
93
94 const size_t buffer_size = 1024 * 1024;
95 std::vector<float> embeddings(buffer_size / sizeof(float));
96 size_t embedding_dim = 0;
97
98 cactus_model_t model = cactus_init(g_transcribe_model_path, nullptr, false);
99 if (!model) {
100 std::cout << "⊘ SKIP │ Failed to init Whisper model\n";
101 return true;
102 }
103
104 std::string audio_path = std::string(g_assets_path) + "/test.wav";
105 Timer t;
106 int result = cactus_audio_embed(model, audio_path.c_str(), embeddings.data(), buffer_size, &embedding_dim);
107 double elapsed = t.elapsed_ms();
108
109 cactus_destroy(model);
110
111 if (result == -1) {
112 std::cout << "⊘ SKIP │ Model doesn't support audio embeddings\n";
113 return true;
114 }
115
116 std::cout << "├─ Embedding dim: " << embedding_dim << "\n"
117 << "└─ Time: " << std::fixed << std::setprecision(2) << elapsed << "ms" << std::endl;
118
119 return result > 0 && embedding_dim > 0;
120}
121
122int main() {
123 TestUtils::TestRunner runner("Embedding Tests");

Callers 1

mainFunction · 0.85

Calls 5

dataMethod · 0.80
elapsed_msMethod · 0.80
cactus_initFunction · 0.50
cactus_audio_embedFunction · 0.50
cactus_destroyFunction · 0.50

Tested by

no test coverage detected