feat(tts): change the speech speed without a restart and keep fast speech clear
MeloTTS's own speed shortens every sound and slurred fast speech (Whisper large-v3 on five Korean sentences, three renders each: 5.5% character errors at 1.5 and 20% at 2.0, against 1.4% at 1.0). The MeloTTS child now speaks at most at its natural pace and makes faster speech with a WSOLA time stretch that keeps the pitch (1.9% at 1.5, 2.2% at 2.0, about 15 ms per 4 s of speech). A voice.tts.speed saved while the services run goes to the worker at once (new tts_speed message) and applies from the next sentence; the client sends it again whenever the worker connects again. Version 0.1.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -503,3 +503,22 @@ async fn ready_tells_the_worker_whether_a_game_runs() {
|
||||
until(|| w.got().iter().any(|g| *g == Got::Json(json!({"type": "llm", "state": "ready", "game": true})))).await;
|
||||
c.close();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn the_speech_speed_goes_out_at_once_and_again_on_every_connection() {
|
||||
let w = FakeWorker::start(0).await;
|
||||
let (c, mut rx) = client(&w.url(), json!({}));
|
||||
c.start();
|
||||
c.wait_ready(Duration::from_secs(2)).await.unwrap();
|
||||
assert!(c.set_tts_speed(1.8), "sent while connected");
|
||||
until(|| w.got().contains(&Got::Json(json!({"type": "tts_speed", "speed": 1.8})))).await;
|
||||
// A restarted worker starts with the speed of its arguments; the latest one set catches it up.
|
||||
let port = w.kill();
|
||||
next_matching(&mut rx, |e| *e == WorkerEvent::Disconnected).await;
|
||||
assert!(!c.set_tts_speed(1.2), "not sent: no connection");
|
||||
let w2 = FakeWorker::start(port).await;
|
||||
until(|| w2.got().iter().any(|g| matches!(g, Got::Json(v) if v["type"] == "tts_speed"))).await;
|
||||
let speeds: Vec<_> = w2.got().into_iter().filter(|g| matches!(g, Got::Json(v) if v["type"] == "tts_speed")).collect();
|
||||
assert_eq!(speeds, [Got::Json(json!({"type": "tts_speed", "speed": 1.2}))]);
|
||||
c.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user