MCPcopy Create free account
hub / github.com/evilsocket/cake / test_mel_spectrogram_sine_wave

Function test_mel_spectrogram_sine_wave

cake-core/src/models/luxtts/mel.rs:202–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

200
201 #[test]
202 fn test_mel_spectrogram_sine_wave() {
203 // 440Hz sine wave, should show energy in the corresponding mel bin
204 let sample_rate = 24000;
205 let duration = 0.5;
206 let n_samples = (sample_rate as f32 * duration) as usize;
207 let samples: Vec<f32> = (0..n_samples)
208 .map(|i| (2.0 * std::f32::consts::PI * 440.0 * i as f32 / sample_rate as f32).sin())
209 .collect();
210 let mel = mel_spectrogram(&samples, 1024, 256, 100, sample_rate, &Device::Cpu, DType::F32).unwrap();
211 let mel_data = mel.to_vec3::<f32>().unwrap();
212 // Should have non-uniform energy distribution across mel bins
213 let max_val: f32 = mel_data[0].iter().flat_map(|row| row.iter()).cloned().fold(f32::NEG_INFINITY, f32::max);
214 let min_val: f32 = mel_data[0].iter().flat_map(|row| row.iter()).cloned().fold(f32::INFINITY, f32::min);
215 assert!(max_val > min_val, "mel spectrogram should show energy variation");
216 }
217}

Callers

nothing calls this directly

Calls 1

mel_spectrogramFunction · 0.85

Tested by

no test coverage detected