mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Split TTS playback speed regression test
Signed-off-by: John Tennant <jtennant@squareup.com>
This commit is contained in:
committed by
John Tennant
parent
80899bab8d
commit
f5a2005500
@@ -920,6 +920,9 @@ fn lock_player_ops(ops: &Mutex<()>) -> MutexGuard<'_, ()> {
|
||||
|
||||
// ── Tests ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tts_playback_speed_tests.rs"]
|
||||
mod playback_speed_tests;
|
||||
#[cfg(test)]
|
||||
#[path = "tts_tests.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
use super::*;
|
||||
|
||||
/// Regression guard: playback decoration happens after speed processing, so
|
||||
/// the fixed device cushion is never time-stretched.
|
||||
#[test]
|
||||
fn playback_speed_preserves_production_sentence_lead_in() {
|
||||
let processed = process_complete_chunk(&vec![0.5; 2_400], 1.5, SAMPLE_RATE)
|
||||
.expect("process synthesized model audio");
|
||||
let mut first = true;
|
||||
let processed =
|
||||
build_sentence_append_buffer(&mut first, processed, 2_400, true, true);
|
||||
|
||||
assert_eq!(SENTENCE_LEAD_IN_SAMPLES, 480);
|
||||
assert!(
|
||||
processed[..SENTENCE_LEAD_IN_SAMPLES]
|
||||
.iter()
|
||||
.all(|&sample| sample == 0.0),
|
||||
"the fixed device cushion must remain pure zero"
|
||||
);
|
||||
assert!(
|
||||
processed[SENTENCE_LEAD_IN_SAMPLES..]
|
||||
.iter()
|
||||
.any(|sample| sample.abs() > 0.1),
|
||||
"speech energy must remain after the fixed device cushion"
|
||||
);
|
||||
}
|
||||
@@ -885,31 +885,6 @@ fn sentence_append_buffer_is_one_contiguous_source() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Regression guard: playback decoration happens after speed processing, so
|
||||
/// the fixed device cushion is never time-stretched.
|
||||
#[test]
|
||||
fn playback_speed_preserves_production_sentence_lead_in() {
|
||||
let processed = process_complete_chunk(&vec![0.5; 2_400], 1.5, SAMPLE_RATE)
|
||||
.expect("process synthesized model audio");
|
||||
let mut first = true;
|
||||
let processed =
|
||||
build_sentence_append_buffer(&mut first, processed, 2_400, true, true);
|
||||
|
||||
assert_eq!(SENTENCE_LEAD_IN_SAMPLES, 480);
|
||||
assert!(
|
||||
processed[..SENTENCE_LEAD_IN_SAMPLES]
|
||||
.iter()
|
||||
.all(|&sample| sample == 0.0),
|
||||
"the fixed device cushion must remain pure zero"
|
||||
);
|
||||
assert!(
|
||||
processed[SENTENCE_LEAD_IN_SAMPLES..]
|
||||
.iter()
|
||||
.any(|sample| sample.abs() > 0.1),
|
||||
"speech energy must remain after the fixed device cushion"
|
||||
);
|
||||
}
|
||||
|
||||
// ── clamp_to_full_scale tests ─────────────────────────────────────────────
|
||||
|
||||
/// In-range speech audio passes through bit-exact — no gain is applied.
|
||||
|
||||
Reference in New Issue
Block a user