| 96 | } |
| 97 | |
| 98 | void run_waveform_case(const engine::audio::RnnoiseModel & model, const std::string & checkpoint, int case_index) { |
| 99 | const auto fixture = engine::assets::open_tensor_source( |
| 100 | asset_path("framework/audio_utilities/rnnoise/" + checkpoint + "_waveform_case" + std::to_string(case_index) + ".safetensors")); |
| 101 | const auto input = fixture->require_f32_tensor("waveform_input"); |
| 102 | const auto expected_output = fixture->require_f32_tensor("waveform_output"); |
| 103 | const auto expected_vad = fixture->require_f32_tensor("waveform_vad"); |
| 104 | require(input.shape.rank == 2 && input.shape.dims[0] == 1, "RNNoise waveform input shape mismatch"); |
| 105 | require(expected_output.shape.rank == 2 && expected_output.shape.dims[0] == 1, "RNNoise waveform output shape mismatch"); |
| 106 | require(expected_vad.shape.rank == 2 && expected_vad.shape.dims[0] == 1, "RNNoise waveform vad shape mismatch"); |
| 107 | const auto actual = model.process_mono_48k(input.values); |
| 108 | require(actual.sample_rate == 48000, "RNNoise sample rate mismatch"); |
| 109 | require_close( |
| 110 | actual.samples, |
| 111 | expected_output.values, |
| 112 | 2.0e-3f, |
| 113 | 2.0e-4, |
| 114 | checkpoint + " waveform case " + std::to_string(case_index)); |
| 115 | require_close( |
| 116 | actual.vad, |
| 117 | expected_vad.values, |
| 118 | 2.5e-5f, |
| 119 | 2.0e-6, |
| 120 | checkpoint + " waveform vad case " + std::to_string(case_index)); |
| 121 | } |
| 122 | |
| 123 | } // namespace |
| 124 |
no test coverage detected