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

Function parse_float_array

tests/test_stt.cpp:36–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34static const char* g_whisper_prompt = get_transcribe_prompt();
35
36static std::vector<float> parse_float_array(const std::string& json, const std::string& key) {
37 std::vector<float> values;
38 std::string search = "\"" + key + "\":[";
39 size_t start = json.find(search);
40 if (start == std::string::npos) return values;
41 start += search.size();
42 size_t end = json.find("]", start);
43 if (end == std::string::npos) return values;
44 const char* p = json.c_str() + start;
45 const char* end_p = json.c_str() + end;
46 while (p < end_p) {
47 char* next;
48 float v = strtof(p, &next);
49 if (next == p) break;
50 values.push_back(v);
51 p = next;
52 while (p < end_p && (*p == ',' || *p == ' ')) ++p;
53 }
54 return values;
55}
56
57bool test_audio_processor() {
58 std::cout << "\n╔══════════════════════════════════════════╗\n"

Callers 2

test_diarizeFunction · 0.70
test_embed_speakerFunction · 0.70

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected