From a65532f3b2a524e21b5620e71ad62fedadc6c61b Mon Sep 17 00:00:00 2001 From: Steve Calcott Date: Tue, 15 Sep 2026 12:21:10 +0000 Subject: [PATCH] Add --instruction and --seed to tts/generate.py --instruction passes through to MOSS-TTS's build_user_message (confirmed to work for emotion in earlier testing) so callers can steer per-line delivery. --seed enables reproducible generation, currently the only way to get determinism out of this pipeline since MOSS-TTS/AuK don't use a fixed-seed workflow the way Qwen3 did. Needed for a downstream per-line episode-generation pipeline (character cards + emotion-tagged script lines). Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Y1oQ4h4WE4R9KRvMQLr5Ey --- tts/generate.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tts/generate.py b/tts/generate.py index b86cf0a..b261b00 100644 --- a/tts/generate.py +++ b/tts/generate.py @@ -31,6 +31,16 @@ def main() -> None: parser.add_argument("--reference", required=True, help="Reference audio path") parser.add_argument("--output", required=True, help="Output wav path") parser.add_argument("--language", default="English", help="Language tag") + parser.add_argument( + "--instruction", default=None, + help='Style/delivery instruction (e.g. "Change the emotion to excited."). ' + "Undocumented MOSS-TTS field for this checkpoint - confirmed to work for " + "emotion in testing, passed through as-is.", + ) + parser.add_argument( + "--seed", type=int, default=None, + help="Random seed for reproducibility. Unset = nondeterministic.", + ) parser.add_argument("--audio_temperature", type=float, default=1.7) parser.add_argument("--audio_top_p", type=float, default=0.8) parser.add_argument("--audio_top_k", type=int, default=25) @@ -41,6 +51,11 @@ def main() -> None: device = "cuda" if torch.cuda.is_available() else "cpu" dtype = torch.bfloat16 if device == "cuda" else torch.float32 + if args.seed is not None: + torch.manual_seed(args.seed) + if device == "cuda": + torch.cuda.manual_seed_all(args.seed) + torch.backends.cuda.enable_cudnn_sdp(False) torch.backends.cuda.enable_flash_sdp(True) torch.backends.cuda.enable_mem_efficient_sdp(True) @@ -65,6 +80,7 @@ def main() -> None: text=args.text, language=args.language, reference=[args.reference], + instruction=args.instruction, ) ]