Skip to content

运行于 Cloudflare Workers 上的微软“大声朗读”转发器。通过简单的 HTTP GET 请求,将文本转换为语音。

Notifications You must be signed in to change notification settings

fuofox/read-aloud

 
 

Repository files navigation

微软“朗读” TTS 转发器

运行于 Cloudflare Workers / Vercel / Node.js (Docker) 上的微软“大声朗读”转发器。通过简单的 HTTP GET 请求,将文本转换为语音。

可以直接使用的资源yy4382#1

“大声朗读” 是什么?

“大声朗读” (Read aloud) 是微软为一系列自家服务提供的文字转语音服务。由于大家基本上都使用的是 Edge 浏览器上的接口,所以也被时常称为 "Edge TTS"。

自行部署

Cloudflare Workers

Deploy to Cloudflare Workers

环境变量设置:在 Cloudflare 面板的当前 Workers 项目中,找到 Settings -> Variables and Secrets,即可添加环境变量。

TOKEN=YOUR_TOKEN # Optional

TOKEN 类似于密码,如果设置,则只有拥有该令牌的请求才能使用该服务。

Vercel

Deploy with Vercel

框架(Framework) 选择 Other,几个 Command 都保持不动(不要 Override)。

环境变量 TOKEN 设置为字母、数字、下划线和连字符的组合(其他特殊字符未被测试是否可用)。TOKEN 类似于密码,如果设置,则只有拥有该令牌的请求才能使用该服务。

最好启用 Fluid Compute,以尽可能复用连接。

由于 Vercel 限制,日志会以 JSON 格式直接输出,而不会被 pino-pretty 格式化。

Node.js (Docker)

docker run -d --name read-aloud -p 3000:3000 -e TOKEN=YOUR_TOKEN yunfinibol/read-aloud:main

记得将 YOUR_TOKEN 替换为你的实际令牌。

TOKEN 类似于密码,如果设置,则只有拥有该令牌的请求才能使用该服务。

更新 Docker 镜像:

# 获取最新镜像
docker pull yunfinibol/read-aloud:main
# 重启容器
docker rm -f read-aloud
docker run -d --name read-aloud -p 3000:3000 -e TOKEN=YOUR_TOKEN yunfinibol/read-aloud:main

API 参考

Swagger 文档:https://ra.yfi.moe/api/ui

相关项目

更多有关听书的信息,请访问 我的听书方法汇总 - Yunfi

Development Notes

How does the bundling / deployment work?

Cloudflare Workers

Deploy to Cloudflare 按钮默认使用 package.json 中 deploy 脚本进行部署。

流程:tsup 打包到 dist-prebuild 目录(pnpm run prebuild:worker)(由 wrangler.toml 中的 build 参数运行该命令),然后 wrangler deploy 将 dist-prebuild/workerd.mjs(由 wrangler.toml 中的 main 参数指定该文件)部署到 Cloudflare Workers。

Vercel

使用了 Custom build step for Node.js 方式

通过 package.json 中的 vercel-build 脚本,Vercel CLI 会执行该命令进行构建,之后 /api/index.mjs 会导入构建结果。

同时,依赖 vercel.json 中的 rewrite 配置,将所有 /api 请求重写到 api/index.mjs 文件。

Cloudflare Typescript types

https://developers.cloudflare.com/workers/languages/typescript/

通过 pnpm run generate-types 脚本,生成 Cloudflare Workers 的 Typescript 类型定义文件。

需要在每次更改 wrangler.toml 文件后运行该脚本。

About

运行于 Cloudflare Workers 上的微软“大声朗读”转发器。通过简单的 HTTP GET 请求,将文本转换为语音。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 73.8%
  • HTML 18.6%
  • JavaScript 5.0%
  • Dockerfile 2.6%