[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-1645":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":15,"stars30d":16,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":17,"rankGlobal":8,"rankLanguage":8,"license":8,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":18,"hasPages":18,"topics":20,"createdAt":8,"pushedAt":8,"updatedAt":21,"readmeContent":22,"aiSummary":23,"trendingCount":14,"starSnapshotCount":14,"syncStatus":15,"lastSyncTime":24,"discoverSource":25},1645,"cloudflare-edge-tts","DIYgod\u002Fcloudflare-edge-tts","DIYgod",null,"TypeScript",194,43,185,1,0,2,10,40.93,false,"main",[],"2026-06-12 04:00:10","# cloudflare-edge-tts\n\nMinimal Cloudflare Worker that exposes Microsoft Edge Text-to-Speech over HTTP using a Worker-native implementation built on `fetch(..., { Upgrade: \"websocket\" })`.\n\n## Endpoints\n\n### `GET \u002Fhealth`\n\nReturns a lightweight health response:\n\n```json\n{\n  \"ok\": true\n}\n```\n\n### `GET \u002Fvoices`\n\nReturns the available Edge TTS voices:\n\n```json\n{\n  \"voices\": [\n    {\n      \"Name\": \"Microsoft Server Speech Text to Speech Voice (en-US, AvaMultilingualNeural)\",\n      \"ShortName\": \"en-US-AvaMultilingualNeural\"\n    }\n  ]\n}\n```\n\nThe `voices` payload includes `ShortName` values. This Worker's default voice is `en-US-AvaMultilingualNeural`. Callers may pass any discovered `ShortName`, and the Worker also accepts certain provider-style aliases when they can be mapped to a compatible Edge TTS voice.\n\n### `POST \u002Ftts`\n\nSynthesizes speech and streams `audio\u002Fmpeg` back to the client.\n\nRequest body:\n\n```json\n{\n  \"text\": \"你好，世界\",\n  \"voice\": \"en-US-AvaMultilingualNeural\"\n}\n```\n\n`voice` is optional. When omitted, the Worker uses `en-US-AvaMultilingualNeural`.\n\nValidation and error behavior:\n\n- Requires `Content-Type: application\u002Fjson`\n- Requires a non-empty string `text`\n- Rejects empty `voice` strings\n- Returns `502` when the upstream TTS request fails before the audio response starts, for example before or while priming the first chunk\n\n## Setup\n\nInstall dependencies:\n\n```bash\nnpm install\n```\n\nGenerate Worker environment types:\n\n```bash\nnpm run cf-typegen\n```\n\n## Development\n\nRemote runtime development with Cloudflare:\n\n```bash\nnpm run dev\n```\n\nLocal runtime development:\n\n```bash\nnpm run dev:local\n```\n\n## Testing\n\nRun the test suite:\n\n```bash\nnpm test\n```\n\nRun TypeScript checks:\n\n```bash\nnpm run typecheck\n```\n\n## Remote Smoke Test\n\nReal-runtime validation uses `wrangler dev --remote`.\n\nConfirm the authenticated Cloudflare account:\n\n```bash\nnpx wrangler whoami\n```\n\nStart the remote dev server on localhost:\n\n```bash\nnpm run dev\n```\n\nUse the actual URL printed by Wrangler if it differs from `http:\u002F\u002F127.0.0.1:8787`.\n\nIn another terminal, run the smoke test:\n\n```bash\ncurl -i --max-time 20 http:\u002F\u002F127.0.0.1:8787\u002Fhealth\ncurl -sS --max-time 20 \\\n  -D \u002Ftmp\u002Fcloudflare-edge-tts-voices.headers \\\n  http:\u002F\u002F127.0.0.1:8787\u002Fvoices \\\n  --output \u002Ftmp\u002Fcloudflare-edge-tts-voices.json && \\\n  awk 'NR==1 { print $2 }' \u002Ftmp\u002Fcloudflare-edge-tts-voices.headers\ncurl -sS --max-time 30 \\\n  -D \u002Ftmp\u002Fcloudflare-edge-tts-tts.headers \\\n  -H 'Content-Type: application\u002Fjson' \\\n  http:\u002F\u002F127.0.0.1:8787\u002Ftts \\\n  --data '{\"text\":\"你好，世界\"}' \\\n  --output \u002Ftmp\u002Fcloudflare-edge-tts-tts.body && \\\n  awk 'NR==1 { print $2 }' \u002Ftmp\u002Fcloudflare-edge-tts-tts.headers && \\\n  file \u002Ftmp\u002Fcloudflare-edge-tts-tts.body\n```\n\nExpected checks:\n\n- `\u002Fhealth` should return `200`\n- `\u002Fvoices` should write headers to `\u002Ftmp\u002Fcloudflare-edge-tts-voices.headers`, write JSON to `\u002Ftmp\u002Fcloudflare-edge-tts-voices.json`, and report an HTTP `200` status\n- The voices response should contain one or more `ShortName` entries\n- `\u002Ftts` should write headers to `\u002Ftmp\u002Fcloudflare-edge-tts-tts.headers`, write the response body to `\u002Ftmp\u002Fcloudflare-edge-tts-tts.body`, and report the HTTP status\n- A successful `\u002Ftts` call should be `200` with `audio\u002Fmpeg`; a failure should remain inspectable as headers plus a non-audio body, such as a JSON error response\n\n## Deployment\n\nDeploy the Worker:\n\n```bash\nnpm run deploy\n```\n\n## Implementation Note\n\nThis Worker does not rely on `edge-tts-universal` at runtime. It performs the voice-list fetch and WebSocket synthesis handshake directly inside the Worker runtime.\n\n## Notes\n\nObserved remote validation result on 2026-04-10 with `wrangler 4.81.1`:\n\n- `npx wrangler whoami` succeeded\n- The authenticated Cloudflare account context used for the run was `1f1d1678a2413a54c944b3081bab5c84`\n- `npm run dev` started `wrangler dev --remote`, uploaded a remote preview, and reported `Ready on http:\u002F\u002Flocalhost:8787`\n- `curl -i --max-time 20 http:\u002F\u002F127.0.0.1:8787\u002Fhealth` returned `200 OK`\n- The `\u002Fvoices` smoke test returned `200`, produced `\u002Ftmp\u002Fcloudflare-edge-tts-voices.headers`, and wrote a JSON payload containing `ShortName` entries to `\u002Ftmp\u002Fcloudflare-edge-tts-voices.json`\n- The `\u002Ftts` smoke test returned `200`, produced `\u002Ftmp\u002Fcloudflare-edge-tts-tts.headers`, and wrote an `audio\u002Fmpeg` body to `\u002Ftmp\u002Fcloudflare-edge-tts-tts.body`\n\nThis means the current Worker-native implementation was verified successfully against both `wrangler dev --local` and `wrangler dev --remote` in this environment.\n","该项目提供了一个基于Cloudflare Workers的轻量级服务，用于通过HTTP接口访问Microsoft Edge的文本转语音功能。其核心功能包括健康检查、获取可用语音列表以及将文本转换为语音并以音频流形式返回给客户端。技术上利用了`fetch(..., { Upgrade: \"websocket\" })`实现WebSocket升级，确保高效的数据传输。适用于需要快速集成高质量TTS服务的应用场景，如网站、移动应用或IoT设备中的语音交互模块。项目采用TypeScript编写，保证了代码质量和可维护性。","2026-06-11 02:45:14","CREATED_QUERY"]