From 5da2d074bc0bbf0bfe47d038f04189fa4c92d575 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 2 Jul 2025 18:58:01 +0200 Subject: [PATCH] Handle stdin in the mlx tts example. --- scripts/tts_mlx.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/tts_mlx.py b/scripts/tts_mlx.py index 050fce5..70dca65 100644 --- a/scripts/tts_mlx.py +++ b/scripts/tts_mlx.py @@ -10,8 +10,8 @@ import argparse import json -from pathlib import Path import queue +import sys import time import numpy as np @@ -105,8 +105,13 @@ def main(): mimi = tts_model.mimi log("info", f"reading input from {args.inp}") - with open(args.inp, "r") as fobj: - text_to_tts = fobj.read().strip() + if args.inp == "-": + if sys.stdin.isatty(): # Interactive + print("Enter text to synthesize (Ctrl+D to end input):") + text_to_tts = sys.stdin.read().strip() + else: + with open(args.inp, "r") as fobj: + text_to_tts = fobj.read().strip() all_entries = [tts_model.prepare_script([text_to_tts])] if tts_model.multi_speaker: