Adding possibility to read the input text from stdin in the CLI (#110)

This commit is contained in:
Mukul bisht
2026-02-12 11:32:42 +01:00
committed by GitHub
parent 70d47c88f8
commit 431878c0db
+8
View File
@@ -1,6 +1,7 @@
import io import io
import logging import logging
import os import os
import sys
import tempfile import tempfile
import threading import threading
from pathlib import Path from pathlib import Path
@@ -243,6 +244,13 @@ def generate(
log_level = logging.ERROR if quiet else logging.INFO log_level = logging.ERROR if quiet else logging.INFO
with enable_logging("pocket_tts", log_level): with enable_logging("pocket_tts", log_level):
if text == "-":
# Read text from stdin
text = sys.stdin.read()
if not text.strip():
logger.error("No input received from stdin.")
raise typer.Exit(code=1)
tts_model = TTSModel.load_model( tts_model = TTSModel.load_model(
config, temperature, lsd_decode_steps, noise_clamp, eos_threshold config, temperature, lsd_decode_steps, noise_clamp, eos_threshold
) )