Handle stdin in the mlx tts example.

This commit is contained in:
Laurent 2025-07-02 18:58:01 +02:00
parent 433dca3751
commit 5da2d074bc

View File

@ -10,8 +10,8 @@
import argparse
import json
from pathlib import Path
import queue
import sys
import time
import numpy as np
@ -105,6 +105,11 @@ def main():
mimi = tts_model.mimi
log("info", f"reading input from {args.inp}")
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()