Download edge-export/tools/stt_eval.cpp from MOH749/yaatal-rnd-artifacts: direct link, hf CLI and curl.
- Browser
- Download file 2.49 kB
-
https://huggingface.co/MOH749/yaatal-rnd-artifacts/resolve/main/edge-export/tools/stt_eval.cpp
- Command line
-
hf download hf://MOH749/yaatal-rnd-artifacts/edge-export/tools/stt_eval.cpp
-
curl -L -o stt_eval.cpp https://huggingface.co/MOH749/yaatal-rnd-artifacts/resolve/main/edge-export/tools/stt_eval.cpp
2.49 kB
| // Transcribe a manifest with speech-core's NemotronMultilingualStt (the runtime we ship on-device), | |
| // streaming 320 ms windows exactly as an app would. | |
| // | |
| // Usage: stt_eval <bundle_dir> <language> <manifest.csv> <provider_label> | |
| // manifest rows: uid,wav_path,reference (no header) | |
| // stdout rows: uid,provider,audio_s,wall_ms,transcript (speech-core bench CSV, '#' header) | |
| int main(int argc, char** argv) { | |
| if (argc != 5) { | |
| std::fprintf(stderr, "usage: %s <bundle_dir> <language> <manifest.csv> <provider>\n", argv[0]); | |
| return 2; | |
| } | |
| const std::string dir = argv[1]; | |
| speech_core::NemotronMultilingualStt stt(dir + "/encoder.onnx", dir + "/decoder.onnx", dir + "/joint.onnx", | |
| dir + "/vocab.json", dir + "/languages.json", | |
| /*hw_accel=*/false); | |
| if (!stt.set_language(argv[2])) { | |
| std::fprintf(stderr, "unknown language %s in languages.json\n", argv[2]); | |
| return 2; | |
| } | |
| std::ifstream manifest(argv[3]); | |
| std::string line; | |
| std::printf("#uid,provider,audio_s,wall_ms,transcript\n"); | |
| while (std::getline(manifest, line)) { | |
| std::stringstream row(line); | |
| std::string uid, wav; | |
| if (!std::getline(row, uid, ',') || !std::getline(row, wav, ',')) continue; | |
| speech_core::WavData audio; | |
| if (!speech_core::load_wav_mono_pcm16(wav, &audio)) { | |
| std::fprintf(stderr, "skip %s: unreadable\n", uid.c_str()); | |
| continue; | |
| } | |
| auto samples = audio.sample_rate == 16000 | |
| ? audio.samples | |
| : speech_core::Resampler::resample(audio.samples.data(), audio.samples.size(), audio.sample_rate, 16000); | |
| const auto t0 = std::chrono::steady_clock::now(); | |
| const auto result = stt.transcribe(samples.data(), samples.size(), 16000); | |
| const double ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count(); | |
| std::string text = result.text; | |
| for (char& c : text) if (c == ',' || c == '\n') c = ' '; | |
| std::printf("%s,%s,%.3f,%.1f,%s\n", uid.c_str(), argv[4], samples.size() / 16000.0, ms, text.c_str()); | |
| std::fflush(stdout); | |
| } | |
| return 0; | |
| } | |