xtekky/gpt4free · error · ValueError

Prompt is empty.

Error message

Prompt is empty.

What it means

ValueError from EdgeTTS.create_async_generator when get_last_message(messages, prompt) returns empty — neither the message list contains any text content nor an explicit prompt argument was passed. EdgeTTS is text-to-speech: it needs the text to speak.

Source

Thrown at g4f/Provider/audio/EdgeTTS.py:51

            voices = asyncio.run(VoicesManager.create())
            cls.default_model = voices.find(Locale=cls.default_locale)[0]["Name"]
            cls.models = [voice["Name"] for voice in voices.voices]
            cls.audio_models = cls.models
        return cls.models

    @classmethod
    async def create_async_generator(
        cls,
        model: str,
        messages: Messages,
        proxy: str = None,
        prompt: str = None,
        audio: dict = {},
        **kwargs,
    ) -> AsyncResult:
        prompt = get_last_message(messages, prompt)
        if not prompt:
            raise ValueError("Prompt is empty.")
        voice = audio.get("voice", model if model and model != cls.model_id else None)
        if not voice:
            voices = await VoicesManager.create()
            if "locale" in audio:
                voices = voices.find(Locale=audio["locale"])
            elif audio.get("language", cls.default_language) != cls.default_language:
                if "-" in audio.get("language"):
                    voices = voices.find(Locale=audio.get("language"))
                else:
                    voices = voices.find(Language=audio.get("language"))
            else:
                voices = voices.find(Locale=cls.default_locale)
            if not voices:
                raise ValueError(
                    f"No voices found for language '{audio.get('language')}' and locale '{audio.get('locale')}'."
                )
            voice = random.choice(voices)["Name"]

View on GitHub (pinned to 973504e177)

Solutions

  1. Pass the text to speak as prompt: create_async_generator(..., prompt='hello')
  2. Ensure messages contains at least one message with non-empty content
  3. Validate input text is non-empty before invoking the audio API

Example fix

# before
await client.speech.create(model='EdgeTTS', text='')

# after
text = text.strip()
if not text:
    raise ValueError('nothing to speak')
await client.speech.create(model='EdgeTTS', text=text)
Defensive patterns

Strategy: validation

Validate before calling

from g4f.Provider.audio.EdgeTTS import get_last_message
text = get_last_message(messages, prompt)
assert text and text.strip(), 'EdgeTTS: no text to synthesize'

Try / catch

try:
    ...  # speech call
except ValueError as e:
    if 'Prompt is empty' in str(e):
        skip_tts()  # nothing to speak; not an error worth crashing on

Prevention

When it happens

Trigger: Calling the EdgeTTS provider with an empty messages list and no prompt kwarg, or messages whose content fields are all empty/None.

Common situations: Building a TTS pipeline that forwards user chat input directly and hitting empty input; role-only messages with empty strings; automated flows where the text step was skipped.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/6b66fb1f71ee3e4c. Report an issue: GitHub.