{"id":3477,"library":"edge-tts","title":"Microsoft Edge TTS Python Library","description":"edge-tts is a Python library (current version 7.2.8) that provides access to Microsoft Edge's online text-to-speech (TTS) service. It allows developers to convert text into natural-sounding speech without needing the Edge browser, Windows, or an API key, by leveraging the same cloud voices used by Edge. The library maintains an active release cadence, frequently updating to address changes in the underlying Microsoft service.","status":"active","version":"7.2.8","language":"en","source_language":"en","source_url":"https://github.com/rany2/edge-tts","tags":["text-to-speech","tts","microsoft-edge","audio","voice-synthesis","asyncio","speech"],"install":[{"cmd":"pip install edge-tts","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Asynchronous HTTP client for communicating with the TTS service.","package":"aiohttp"},{"reason":"Used for generating subtitle files alongside audio.","package":"srt"},{"reason":"Used for formatting output in CLI tools, like --list-voices.","package":"tabulate"},{"reason":"Optional command-line player required for the `edge-playback` CLI utility (not for the Python library itself).","package":"mpv","optional":true}],"imports":[{"note":"The package name is `edge-tts` for installation, but the module name for import is `edge_tts` (using an underscore).","wrong":"import edge-tts","symbol":"edge_tts","correct":"import edge_tts"}],"quickstart":{"code":"import asyncio\nimport edge_tts\nimport os\n\nTEXT = \"Hello, this is a test of the Microsoft Edge Text-to-Speech library.\"\nVOICE = \"en-US-JennyNeural\" # You can list available voices with `edge-tts --list-voices`\nOUTPUT_FILE = \"hello.mp3\"\n\nasync def main():\n    print(f\"Generating speech for: '{TEXT}' with voice '{VOICE}'\")\n    try:\n        communicate = edge_tts.Communicate(text=TEXT, voice=VOICE)\n        await communicate.save(OUTPUT_FILE)\n        print(f\"Audio saved to {OUTPUT_FILE}\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Ensure you have a stable internet connection and the voice name is correct.\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())","lang":"python","description":"This quickstart demonstrates how to convert a text string into an MP3 audio file using a specified voice. It uses `asyncio` for asynchronous operations, which is fundamental to how `edge-tts` works. Replace 'en-US-JennyNeural' with your desired voice; you can list all available voices using the command-line tool `edge-tts --list-voices`."},"warnings":[{"fix":"Always keep the `edge-tts` library updated to the latest version to incorporate fixes for upstream API changes. Monitor the GitHub repository for immediate updates.","message":"The library relies on a reverse-engineered Microsoft API, which is subject to unannounced changes by Microsoft. This can lead to sudden breakages or requiring rapid updates to the `edge-tts` library to maintain functionality.","severity":"breaking","affected_versions":"All versions, especially during major Microsoft API changes (e.g., around December 2025 where multiple patches were released)."},{"fix":"Avoid using complex or custom SSML tags. Only basic prosody adjustments (rate, volume, pitch) are reliably supported. For advanced speech customization, consider official Azure Cognitive Services TTS which offers full SSML support.","message":"Support for custom SSML (Speech Synthesis Markup Language) beyond basic prosody (rate, volume, pitch) was removed because Microsoft's service only permits SSML that could be generated by Microsoft Edge itself, limiting advanced custom tags.","severity":"breaking","affected_versions":"Versions 7.2.0 and later."},{"fix":"Ensure your code structure uses `async def` for functions interacting with `edge_tts` and invokes the main async function using `asyncio.run(your_async_function())`.","message":"Since `edge-tts` uses `asyncio`, all calls to `Communicate` methods (like `save()` or `stream()`) must be `await`ed within an `async` function, and the main execution flow needs `asyncio.run()`.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Verify the voice name is exact and currently available using `edge-tts --list-voices`. Check your internet connection. Implement error handling and retry logic, or try a different voice/locale if the issue persists.","message":"Encountering 'NoAudioReceived' errors or unexpected silence is common. This often indicates issues with the chosen voice, network connectivity, or temporary service unavailability on Microsoft's end.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Migrate any code relying on `merge_cues` or `words-in-cue` to use `SentenceBoundary` events for cue synchronization. The library now defaults to `SentenceBoundary` cues.","message":"The `merge_cues` support and `words-in-cue` functionality were dropped as `SentenceBoundary` metadata became the default and rendered them obsolete.","severity":"deprecated","affected_versions":"Versions 7.2.0 and later."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}