gitmyhub

cloudflare-edge-tts

TypeScript ★ 195 updated 2mo ago

This is a minimal server that runs on Cloudflare's edge network (their globally distributed serverless platform) and exposes Microsoft Edge's text-to-speech service over a simple web API. The problem it solves is giving developers a straightforward HTTP endpoint they can call to convert text into spoken audio, without needing to set up complex infrastructure.

The server exposes three endpoints: a health check, a route that lists available voices, and a route that accepts text and returns an MP3 audio stream. You send it a JSON body with the text you want spoken and optionally a voice name, and it streams back the audio. Under the hood it connects to Microsoft's Edge TTS service using a WebSocket connection, which it handles natively within the Cloudflare Worker environment.

You would use this if you want to add text-to-speech to a web app or tool and prefer a self-hosted solution running on Cloudflare rather than relying on a third-party TTS API directly. It is written in TypeScript and deployed as a Cloudflare Worker using Wrangler, the standard deployment tool for that platform.