npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

auto-tts

v0.5.0

Published

Unlimited text to speech with selectable voices and speaking tones, powered by edge-tts.

Readme

auto-tts

基于 edge-tts 的无限量文本转语音工具。输入文本,挑一个音色和语气,队列会把它们合成成 mp3,可在线试听和下载。

不需要 API Key,不按字数收费,长文本和批量任务都能排队处理。

auto-tts 界面预览

安装

先确认本机有 Node.js 和 Python:

| 依赖 | 版本 | 说明 | | --- | --- | --- | | Node.js | 18 或更高 | 运行 auto-tts 命令 | | Python | 3.9 或更高 | 后端运行时 |

然后全局安装:

npm i -g auto-tts

启动

auto-tts web

首次启动会在 ~/.local/share/auto-tts/venv 建一个独立的 Python 环境并安装后端依赖(只需一次)。等服务就绪后,它会自动打开浏览器,并在终端打印网页地址:

http://127.0.0.1:8000

按 Ctrl+C 停止服务。

Debian / Ubuntu 上如果提示无法创建虚拟环境,需要先装 python3-venv:

sudo apt install python3-venv

常用参数

auto-tts web --port 9000     # 换一个端口(默认 8000)
auto-tts web --host 0.0.0.0  # 允许局域网内其它设备访问
auto-tts web --no-open       # 不自动打开浏览器
auto-tts web --reset         # 重建 Python 环境后启动
auto-tts say "你好" -o hello.mp3  # 直接合成 mp3,不启动服务
auto-tts voices              # 查看可用音色
auto-tts --help              # 查看全部用法
auto-tts --version           # 查看版本

直接合成(无需启动服务)

auto-tts 也可以当作普通命令行工具使用,直接调用 edge-tts,不启动 Web 服务:

auto-tts say "你好,世界" -o hello.mp3             # 合成到文件
auto-tts say "你好" -o hello.mp3 --srt             # 同时生成同名字幕
echo "很长的文章" | auto-tts say - -o article.mp3  # 文本从 stdin 读入
auto-tts say --file article.txt -v zh-CN-YunxiNeural -t newscast -o article.mp3
auto-tts say "stream" -o - > out.mp3               # 音频写到 stdout
auto-tts say --batch -f scenes.txt -o out/ --srt   # 空行分段,每段生成独立 mp3+SRT
cat scenes.txt | auto-tts say - --batch -o out/ --srt --json
auto-tts voices --locale zh-CN --gender female
auto-tts tones                                     # 查看语气预设

文本可以来自参数、-(stdin)或 --file;-o 省略时在当前目录生成 auto-tts-<时间戳>.mp3;音色默认 zh-CN-XiaoxiaoNeural(与网页版一致),-t/--tone 可用 auto-tts tones 查看,--rate/--volume/--pitch 会覆盖语气预设。完整参数见 auto-tts say --help。

--batch 把输入按空行分段(与网页版批量模式一致),每段生成一个独立的 mp3:-o 此时是输出目录(省略时新建 auto-tts-<时间戳>/),--srt 会为每段生成同名字幕,文件按 001.mp3、002.mp3 顺序编号(段数多时自动扩位)。单段失败不会中断其余分段,全部成功时退出码为 0,否则为 1。

给脚本和 Agent 用的 --json

say、voices、tones 都支持 --json:成功时 stdout 只输出一个 JSON 对象,失败时输出 {"ok": false, "error": "..."} 并以非零退出码结束。进度和提示始终走 stderr,便于管道和自动解析。

auto-tts voices --locale zh --json
# {"ok": true, "count": 14, "voices": [{"name": "zh-CN-XiaoxiaoNeural", ...}]}

auto-tts say "内容" -o out.mp3 --srt --json
# {"ok": true, "path": "/abs/out.mp3", "srt_path": "/abs/out.srt", "size_bytes": 27936, ...}

auto-tts say --batch -f scenes.txt -o out/ --srt --json
# {"ok": true, "dir": "out", "count": 2, "succeeded": 2, "failed": 0,
#  "results": [{"index": 1, "path": "out/001.mp3", "srt_path": "out/001.srt", "ok": true, ...}, ...]}

auto-tts web --no-open --json
# 服务就绪后输出一行:{"url": "http://127.0.0.1:8000", "host": "127.0.0.1", "port": 8000}

批量模式下若部分分段失败,ok 为 false,results 中逐项给出 error,其余分段照常生成,退出码为 1。

功能

  • 音色:322 个 edge-tts 音色,可按语言区域或名称筛选
  • 语气:自然、温柔、愉悦、兴奋、严肃、悲伤、新闻播报、低语,另有自定义
  • 长文本:自动分块合成,长度不限
  • 批量队列:用空行分隔多段文本,每段成为一个独立任务
  • 任务面板:实时进度、失败原因、试听、下载 mp3
  • 字幕导出:任务完成后可下载与音频逐句对齐的 SRT 字幕
  • 命令行:say 直接合成 mp3,--batch 按空行分段批量生成 mp3 和 SRT,voices/tones 查询音色和语气,支持 --json,方便脚本和 Agent 调用

关于语气

edge-tts 本身不支持真正的情感风格(微软服务端会拒绝 <mstts:express-as> 一类的请求),所以这里的语气是用语速、音调、音量三个参数组合近似出来的预设。选中预设会自动填写这三个滑块,手动拖动任一滑块则切回「自定义」。所有预设定义在 backend/app/tts.py 的 TONE_PRESETS。

数据存放位置

生成内容和运行环境都放在用户目录,不会写进 node_modules:

~/.local/share/auto-tts/
├── venv/                 # Python 虚拟环境(依赖指纹 .requirements.sha256 存在此处)
└── data/audio/           # 生成的 mp3

requirements.txt 改动后,下次启动会自动识别并重装依赖。设置环境变量 AUTO_TTS_VENV_DIR 可以把虚拟环境放到别处(例如复用源码目录下的 .venv)。

从源码运行

如果你想改代码,把仓库克隆下来:

git clone https://github.com/kms413/auto-tts.git
cd auto-tts
./start.sh          # 建 venv、装依赖、构建前端、单端口启动
./start.sh --dev    # 开发模式:后端热重载 + Vite 开发服务器
./start.sh --rebuild

./start.sh 与 auto-tts web 效果一致,区别是使用仓库内的 .venv 和源码构建产物。

HTTP 接口

服务同时托管页面和 API,全部挂在同一个端口下:

| 方法 | 路径 | 说明 | | --- | --- | --- | | GET | /api/health | 健康检查 | | GET | /api/voices | 全部可用音色 | | GET | /api/tones | 语气预设及其对应的语速/音调/音量 | | POST | /api/jobs | 创建任务,text 单条或 texts 批量 | | GET | /api/jobs | 任务列表 | | GET | /api/jobs/{id} | 单个任务 | | DELETE | /api/jobs/{id} | 删除任务 | | GET | /api/audio/{filename} | 获取音频文件 | | GET | /api/subtitles/{filename} | 获取 SRT 字幕文件 |

技术栈

  • 后端:FastAPI + edge-tts,任务队列为进程内异步队列
  • 前端:React + TypeScript + Vite

许可

GNU Affero General Public License v3.0 或更新版本(AGPL-3.0-or-later),完整条款见 LICENSE。

Copyright (C) 2026 kms413

AGPL 第 13 条要求以网络方式提供服务的程序向用户提供获取源代码的途径,因此页面底部保留了「获取源代码」链接,请勿移除。