不用花一分钱!教你搭建专属文字转语音网站

准备工作

你只需要:

  • 一个GitHub账号
  • 一个Cloudflare账号(免费)
  • 5分钟时间

第一步:获取项目代码

  1. 访问项目地址:https://github.com/wangwangit/tts
  2. 点击右上角的 Fork 按钮,将项目复制到你的GitHub账号

第二步:一键部署到Cloudflare Workers

  1. 注册Cloudflare账号

  2. 一键部署

    • 点击项目中的部署按钮:

    • 授权GitHub访问权限
    • 选择要部署的仓库

    • 等待部署完成
  3. 获取访问地址

    • 部署成功后,你会得到一个类似 https://your-app.workers.dev 的地址
    • 这就是你的专属语音合成网站!

第三步:自定义域名(可选)

  1. 在Cloudflare控制台中找到你的Worker
  2. 添加自定义域名
  3. 配置DNS解析

API调用示例

// 基础调用
const response = await fetch('https://your-domain.com/v1/audio/speech', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        input: "你好,这是一个测试",
        voice: "zh-CN-XiaoxiaoNeural",
        speed: 1.0,
        pitch: "0",
        style: "general"
    })
});

const audioBlob = await response.blob();

批量处理脚本

# 批量转换文本文件
for file in *.txt; do
    curl -X POST "https://your-domain.com/v1/audio/speech" \
      -H "Content-Type: application/json" \
      -d "{\"input\": \"$(cat $file)\", \"voice\": \"zh-CN-XiaoxiaoNeural\"}" \
      --output "${file%.txt}.mp3"
done

原文: https://mp.weixin.qq.com/s/F4-Pc6etHVXExGhPATLppw

101 个赞

你不光会打篮球,连代码都这么溜 :laughing:

3 个赞

先收藏,暂时用不上

我只是一个无情的AI工具人 :rofl:

你写的多,你有道理!

stars了,以后可能用得上

好东西啊,稀缺

收藏收藏

又学到新东西了哇

感谢佬友教程分享~先收藏啦~

咱们ikun就是这么溜 :grinning_face_with_smiling_eyes:

厉害啊大佬,马上部署

:hushed_face:这个不错啊
mark一下

感谢鸡哥z

既然可以这样,那我OWU的极高延时的STT可以参考你的思路用edge浏览器的STT?

感谢大佬教程

之前见过很多这个文字转语音,原来是出自这个项目,我说角色咋都一样呢

哈哈,都是edge tts :rofl:

1 个赞

这是调用哪里的模型?

感谢大佬分享