babysor/MockingBird · error · ValueError

Input text is empty.

Error message

Input text is empty.

What it means

ValueError raised by main() when the effective input text is empty after reading from --text or --text-file and stripping whitespace. TTS synthesis requires non-empty text.

Source

Thrown at skills/speak/scripts/noiz_tts.py:162

    parser.add_argument(
        "--duration",
        type=float,
        default=None,
        metavar="SEC",
        help="Target audio duration in seconds (0, 36], optional",
    )
    parser.add_argument("--timeout-sec", type=int, default=120)
    args = parser.parse_args()
    args.api_key = normalize_api_key_base64(args.api_key)

    try:
        if args.text_file:
            text = Path(args.text_file).read_text(encoding="utf-8").strip()
        else:
            text = args.text

        if not text:
            raise ValueError("Input text is empty.")

        if len(text) > 5000:
            print(
                f"Warning: text is {len(text)} chars (max 5000). "
                "Consider chunking for long texts.",
                file=sys.stderr,
            )

        if args.auto_emotion:
            text = call_emotion_enhance(
                args.base_url, args.api_key, text, args.timeout_sec
            )

        ref = Path(args.reference_audio) if args.reference_audio else None
        out_duration = synthesize(
            base_url=args.base_url,
            api_key=args.api_key,
            text=text,

View on GitHub (pinned to 28dc5e14f1)

Solutions

  1. Check the file/argument actually contains content before running
  2. Validate upstream producers that generate the text file
  3. Fail fast in shell: [ -s input.txt ] || exit 1

Example fix

# before
python noiz_tts.py --text-file empty.txt ...
# after
[ -s input.txt ] || { echo "input empty"; exit 1; }
python noiz_tts.py --text-file input.txt ...
Defensive patterns

Strategy: validation

Validate before calling

text = (Path(args.text_file).read_text(encoding='utf-8') if args.text_file else args.text).strip()
if not text:
    sys.exit('Input text is empty.')

Try / catch

try:
    main()
except ValueError as e:
    sys.exit(str(e)) if 'empty' in str(e) else raise_

Prevention

When it happens

Trigger: Passing --text "" or whitespace-only string; passing --text-file pointing at an empty file or one containing only whitespace/newlines.

Common situations: Empty input file from a previous failed pipeline step, whitespace-only argument from unquoted shell expansion, or wrong file passed via --text-file.

Related errors


AI-assisted analysis of babysor/MockingBird@28dc5e14f1 (2026-08-27). Data as JSON: /api/errors/6150cc95f7c0731e. Report an issue: GitHub.