{"record":{"id":"6b66fb1f71ee3e4c","repo":"xtekky/gpt4free","slug":"prompt-is-empty","errorCode":null,"errorMessage":"Prompt is empty.","messagePattern":"Prompt is empty\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/audio/EdgeTTS.py","lineNumber":51,"sourceCode":"            voices = asyncio.run(VoicesManager.create())\n            cls.default_model = voices.find(Locale=cls.default_locale)[0][\"Name\"]\n            cls.models = [voice[\"Name\"] for voice in voices.voices]\n            cls.audio_models = cls.models\n        return cls.models\n\n    @classmethod\n    async def create_async_generator(\n        cls,\n        model: str,\n        messages: Messages,\n        proxy: str = None,\n        prompt: str = None,\n        audio: dict = {},\n        **kwargs,\n    ) -> AsyncResult:\n        prompt = get_last_message(messages, prompt)\n        if not prompt:\n            raise ValueError(\"Prompt is empty.\")\n        voice = audio.get(\"voice\", model if model and model != cls.model_id else None)\n        if not voice:\n            voices = await VoicesManager.create()\n            if \"locale\" in audio:\n                voices = voices.find(Locale=audio[\"locale\"])\n            elif audio.get(\"language\", cls.default_language) != cls.default_language:\n                if \"-\" in audio.get(\"language\"):\n                    voices = voices.find(Locale=audio.get(\"language\"))\n                else:\n                    voices = voices.find(Language=audio.get(\"language\"))\n            else:\n                voices = voices.find(Locale=cls.default_locale)\n            if not voices:\n                raise ValueError(\n                    f\"No voices found for language '{audio.get('language')}' and locale '{audio.get('locale')}'.\"\n                )\n            voice = random.choice(voices)[\"Name\"]\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/audio/EdgeTTS.py#L33-L69","documentation":"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.","triggerScenarios":"Calling the EdgeTTS provider with an empty messages list and no prompt kwarg, or messages whose content fields are all empty/None.","commonSituations":"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.","solutions":["Pass the text to speak as prompt: create_async_generator(..., prompt='hello')","Ensure messages contains at least one message with non-empty content","Validate input text is non-empty before invoking the audio API"],"exampleFix":"# before\nawait client.speech.create(model='EdgeTTS', text='')\n\n# after\ntext = text.strip()\nif not text:\n    raise ValueError('nothing to speak')\nawait client.speech.create(model='EdgeTTS', text=text)","handlingStrategy":"validation","validationCode":"from g4f.Provider.audio.EdgeTTS import get_last_message\ntext = get_last_message(messages, prompt)\nassert text and text.strip(), 'EdgeTTS: no text to synthesize'","typeGuard":null,"tryCatchPattern":"try:\n    ...  # speech call\nexcept ValueError as e:\n    if 'Prompt is empty' in str(e):\n        skip_tts()  # nothing to speak; not an error worth crashing on","preventionTips":["Strip and check text before calling TTS endpoints","Skip TTS silently for empty user input rather than erroring"],"tags":["edgetts","tts","validation","empty-input"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}