腾讯云 EdgeOne Pages 部署 EdgeTTS:全球加速方案
<ul><li><h1 id="-edgeone-pages-edgetts--3" class="heading-1" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.5rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 2rem; border-bottom: 2px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">腾讯云 EdgeOne Pages 部署 EdgeTTS:全球加速方案<a href="https://md.aiqgc.com/#-edgeone-pages-edgetts--3" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h1><h2 id="--15" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">项目概述<a href="https://md.aiqgc.com/#--15" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">原项目:GitHub - icheer/edgetts-cloudflare-workers-webui</p><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">这是一个部署于 Cloudflare Workers 的高性能文本转语音(TTS)代理服务。它将微软 Edge 强大且自然的语音合成能力,封装为兼容 OpenAI API 格式的接口,使开发者能够无缝对接各类现有应用至这一免费、高质量的 TTS 服务。</p><h2 id="--16" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">当前版本<a href="https://md.aiqgc.com/#--16" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">本代码由腾讯云工程师依据上述 GitHub 项目修改适配,支持通过腾讯云 EdgeOne Pages 一键部署,实现全球加速。</p><h2 id="--17" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">使用地址<a href="https://md.aiqgc.com/#--17" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><a href="https://edgetts-pcw8ynxscw.edgeone.run/?eo_token=2344a26df16b055dfb30f3c3ea00fa61&eo_time=1757577752" style="box-sizing: border-box; color: rgb(37, 99, 235); text-decoration-line: none; border-bottom: 1px solid transparent; transition: 0.2s;">https://edgetts-pcw8ynxscw.edgeone.run?eo_token=2344a26df16b055dfb30f3c3ea00fa61&eo_time=1757577752</a></p><h2 id="api--3" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">API 配置<a href="https://md.aiqgc.com/#api--3" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><ul style="margin-top: 1rem; margin-bottom: 1rem; padding-left: 2rem; box-sizing: border-box; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">API Base URL</strong>:<a href="https://edgetts-pcw8ynxscw.edgeone.run/" style="box-sizing: border-box; color: rgb(37, 99, 235); text-decoration-line: none; border-bottom: 1px solid transparent; transition: 0.2s;">https://edgetts-pcw8ynxscw.edgeone.run</a></li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">API Key</strong>:123456789</li></ul><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">【优化后文章】</p><h1 id="-edge-tts-cloudflare-worker-" class="heading-1" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.5rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 2rem; border-bottom: 2px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">高性能 Edge TTS Cloudflare Worker 代理<a href="https://md.aiqgc.com/#-edge-tts-cloudflare-worker-" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h1><h2 id="--18" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">项目概述<a href="https://md.aiqgc.com/#--18" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">这是一个部署于 Cloudflare Workers 的高性能文本转语音(TTS)代理服务。它将微软 Edge 强大且自然的语音合成能力,封装为兼容 OpenAI API 格式的接口,使开发者能够无缝对接各类现有应用至这一免费、高质量的 TTS 服务。</p><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">项目包含两个核心文件:</p><ul style="margin-top: 1rem; margin-bottom: 1rem; padding-left: 2rem; box-sizing: border-box; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">workers.js</strong>:部署于 Cloudflare 的核心服务脚本。</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">webui.html</strong>:功能完备的本地测试网页。</li></ul><h2 id="--19" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">功能亮点<a href="https://md.aiqgc.com/#--19" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><ul style="margin-top: 1rem; margin-bottom: 1rem; padding-left: 2rem; box-sizing: border-box; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">OpenAI 兼容</strong>:完全模拟 OpenAI 的 <code style="padding: 0.125rem 0.375rem; box-sizing: border-box; background: rgb(241, 245, 249); border-radius: 0.25rem; font-family: "Fira Mono", Monaco, Consolas, monospace; font-size: 0.875em; color: rgb(220, 38, 38);">/v1/audio/speech</code> 接口,可直接被官方 SDK 或现有工具调用。</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">高质量音色</strong>:利用微软 Edge TTS 提供的多种自然流畅的神经网络语音。</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">流式响应</strong>:支持流式与标准两种模式,流式可显著降低长文本的首次播放延迟。</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">智能文本清理</strong>:内置完善清理流水线,自动处理复制文本中的杂质,包括:<ul style="margin-top: 1rem; margin-bottom: 1rem; padding-left: 2rem; box-sizing: border-box;"><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">移除 Markdown 格式;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">移除 Emoji;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">移除 URL;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">智能移除引用标记数字(保留年份、数量等有意义数字);</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">移除多余空格与硬换行,确保中文听感连贯;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">支持自定义关键词过滤。</li></ul></li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">灵活参数配置</strong>:支持动态调整音色、语速、音调、分块大小、并发数及所有清理选项。</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">零依赖部署</strong>:脚本完全自包含,无需 KV、队列等外部服务。</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">便捷测试工具</strong>:提供功能丰富的 Web UI,无需编写代码即可完成测试。</li></ul><h2 id="--20" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">工作原理<a href="https://md.aiqgc.com/#--20" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">该 Worker 充当智能中间层:</p><ol style="margin-top: 1rem; margin-bottom: 1rem; padding-left: 2rem; box-sizing: border-box; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">接收与 OpenAI TTS API 完全一致的 POST 请求;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">立即执行文本清理流水线;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">根据文本长度智能决策处理模式——短文本采用同步直通,长文本自动启用自我调节分块机制;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">将文本分割并以指定并发数向微软 Edge TTS 服务器请求;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">标准模式下拼接完整 MP3 后返回;流式模式下收到首块即开始推送,实现低延迟播放。</li></ol><h2 id="--21" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">部署指南<a href="https://md.aiqgc.com/#--21" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">部署仅需数分钟。</p><h3 id="--22" class="heading-3" style="margin-top: 1.5rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.25rem; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">准备工作<a href="https://md.aiqgc.com/#--22" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h3><ul style="margin-top: 1rem; margin-bottom: 1rem; padding-left: 2rem; box-sizing: border-box; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">一个 Cloudflare 账户(免费版即可)。</li></ul><h3 id="-worker" class="heading-3" style="margin-top: 1.5rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.25rem; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">步骤一:创建 Worker<a href="https://md.aiqgc.com/#-worker" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h3><ol style="margin-top: 1rem; margin-bottom: 1rem; padding-left: 2rem; box-sizing: border-box; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">登录 Cloudflare 仪表板;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">进入「Workers 和 Pages」;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">点击「创建应用程序」→「创建 Worker」;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">输入唯一名称(如 my-edge-tts-proxy)并部署。</li></ol><h3 id="--23" class="heading-3" style="margin-top: 1.5rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.25rem; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">步骤二:配置代码与密钥<a href="https://md.aiqgc.com/#--23" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h3><ol style="margin-top: 1rem; margin-bottom: 1rem; padding-left: 2rem; box-sizing: border-box; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">进入编辑器,删除默认代码,粘贴 workers.js 全部内容;</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">在「设置」→「变量」中添加机密变量:<ul style="margin-top: 1rem; margin-bottom: 1rem; padding-left: 2rem; box-sizing: border-box;"><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">名称:API_KEY</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;">值:自行设定复杂密钥(如 sk-my-super-secret-key-12345)。</li></ul></li></ol><h3 id="--24" class="heading-3" style="margin-top: 1.5rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.25rem; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">步骤三:保存并部署<a href="https://md.aiqgc.com/#--24" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h3><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">点击右上角「保存并部署」。服务地址即为 https://<名称>.<子域>.workers.dev。</p><h3 id="-web-ui" class="heading-3" style="margin-top: 1.5rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.25rem; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">步骤四:使用 Web UI<a href="https://md.aiqgc.com/#-web-ui" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h3><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">项目已将完整 Web UI 嵌入 worker.js,直接访问部署后的 URL 即可使用本地保存的 webui.html 仅作归档参考。</p><h2 id="api--4" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">API 使用指南<a href="https://md.aiqgc.com/#api--4" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><strong style="box-sizing: border-box;">端点</strong><br style="box-sizing: border-box;">POST https://<您的 Worker URL>/v1/audio/speech</p><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><strong style="box-sizing: border-box;">认证</strong></p><div class="code-wrapper" data-language="text" data-raw-code="Authorization%3A%20Bearer%20YOUR_API_KEY" style="margin-top: 1.5rem; margin-bottom: 1.5rem; box-sizing: border-box; position: relative; border-radius: 0.5rem; overflow: hidden; border: 1px solid rgb(226, 232, 240); color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><div class="code-lang" style="padding: 0.25rem 0.5rem; box-sizing: border-box; position: absolute; top: 0.5rem; left: 0.5rem; background: rgb(55, 65, 81); color: white; font-size: 0.75rem; border-radius: 0.25rem; z-index: 2;">Plain Text</div><div class="code-content" style="box-sizing: border-box; position: relative; overflow-x: auto;"><pre style="padding: 2.5rem 1rem 1rem; box-sizing: border-box; background: rgb(30, 41, 59); border-radius: 0.5rem; overflow-x: auto; box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px; font-family: "Fira Mono", Monaco, Consolas, monospace; font-size: 0.875rem; line-height: 1.5;"><code class="hljs language-text language-plaintext" data-highlighted="yes" style="padding: 1em; box-sizing: border-box; background: none; color: rgb(226, 232, 240); border-radius: 0.25rem; font-family: "Fira Mono", Monaco, Consolas, monospace; font-size: 0.875rem; display: block; overflow-x: auto;">Authorization: Bearer YOUR_API_KEY</code></pre></div><button class="code-copy-btn" title="复制代码" style="padding: 0.5rem; position: absolute; top: 0.5rem; right: 0.5rem; background: rgba(0, 0, 0, 0.5); border-width: initial; border-style: none; border-color: initial; color: white; border-radius: 0.25rem; cursor: pointer; transition: 0.2s; z-index: 2;"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 11H3a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-7a2 2 0 0 0-2-2z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M15 3h6a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-1" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><strong style="box-sizing: border-box;">主要请求参数</strong>(JSON)</p><div class="table-wrapper" style="margin-top: 1.5rem; margin-bottom: 1.5rem; box-sizing: border-box; overflow-x: auto; border-radius: 0.5rem; box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><table class="enhanced-table" style="margin-top: 1.5rem; margin-bottom: 1.5rem; width: 643.5px; border-radius: 0.5rem; overflow: hidden; box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px;"><thead style="box-sizing: border-box;"><tr style="box-sizing: border-box;"><th style="padding: 0.75rem 1rem; box-sizing: border-box; text-align: left; border-bottom: 1px solid rgb(226, 232, 240); background: rgb(248, 250, 252); font-weight: 600; color: rgb(55, 65, 81); position: sticky; top: 0px; z-index: 1;">参数</th><th style="padding: 0.75rem 1rem; box-sizing: border-box; text-align: left; border-bottom: 1px solid rgb(226, 232, 240); background: rgb(248, 250, 252); font-weight: 600; color: rgb(55, 65, 81); position: sticky; top: 0px; z-index: 1;">类型</th><th style="padding: 0.75rem 1rem; box-sizing: border-box; text-align: left; border-bottom: 1px solid rgb(226, 232, 240); background: rgb(248, 250, 252); font-weight: 600; color: rgb(55, 65, 81); position: sticky; top: 0px; z-index: 1;">默认值</th><th style="padding: 0.75rem 1rem; box-sizing: border-box; text-align: left; border-bottom: 1px solid rgb(226, 232, 240); background: rgb(248, 250, 252); font-weight: 600; color: rgb(55, 65, 81); position: sticky; top: 0px; z-index: 1;">说明</th></tr></thead><tbody style="box-sizing: border-box;"><tr style="box-sizing: border-box; transition: background-color 0.2s;"><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">model</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">string</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">"tts-1"</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">支持 tts-1、tts-1-hd 或映射音色</td></tr><tr style="box-sizing: border-box; transition: background-color 0.2s; background: rgb(251, 251, 251);"><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">input</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">string</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">—</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">必需,待合成文本</td></tr><tr style="box-sizing: border-box; transition: background-color 0.2s;"><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">voice</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">string</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">"zh-CN-XiaoxiaoNeural"</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">微软音色名称</td></tr><tr style="box-sizing: border-box; transition: background-color 0.2s; background: rgb(251, 251, 251);"><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">speed</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">number</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">1.0</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">0.25–2.0</td></tr><tr style="box-sizing: border-box; transition: background-color 0.2s;"><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">pitch</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">number</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">1.0</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">音调调整</td></tr><tr style="box-sizing: border-box; transition: background-color 0.2s; background: rgb(251, 251, 251);"><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">stream</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">boolean</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">false</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">是否流式响应</td></tr><tr style="box-sizing: border-box; transition: background-color 0.2s;"><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">concurrency</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">number</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">10</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">并发请求数</td></tr><tr style="box-sizing: border-box; transition: background-color 0.2s; background: rgb(251, 251, 251);"><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">chunk_size</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">number</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">300</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">分块字符数(会自动调整)</td></tr><tr style="box-sizing: border-box; transition: background-color 0.2s;"><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">cleaning_options</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">object</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">{...}</td><td style="padding: 0.75rem 1rem; box-sizing: border-box; border-bottom-color: rgb(226, 232, 240);">文本清理开关(详见功能亮点)</td></tr></tbody></table></div><h2 id="--25" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">重要限制<a href="https://md.aiqgc.com/#--25" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><p style="margin-top: 1rem; margin-bottom: 1rem; box-sizing: border-box; line-height: 1.7; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;">为稳定运行于 Cloudflare 免费套餐,单次请求文本上限约 12 万字符,超出将返回清晰错误提示,已足以覆盖绝大多数长文场景。</p><h2 id="--26" class="heading-2" style="margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.25rem; box-sizing: border-box; line-height: 1.3; color: rgb(30, 41, 59); position: relative; transition: 0.3s; font-size: 1.5rem; border-bottom: 1px solid rgb(226, 232, 240); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;">项目文件说明<a href="https://md.aiqgc.com/#--26" class="heading-anchor" style="box-sizing: border-box; position: absolute; left: -1.5rem; color: rgb(37, 99, 235); text-decoration-line: none; font-weight: 400; opacity: 0; transition: 0.2s; border-bottom: 1px solid transparent;">#</a></h2><ul style="margin-top: 1rem; margin-bottom: 1rem; padding-left: 2rem; box-sizing: border-box; color: rgb(30, 41, 59); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: medium;"><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">workers.js</strong>:唯一需部署文件,包含完整 API 逻辑、文本清理与 Web UI。</li><li style="margin-top: 0.5rem; margin-bottom: 0.5rem; margin-left: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">webui.html</strong>:独立测试页面,可本地打开,亦已嵌入 workers.js 中。</li></ul></li></ul>
页:
[1]