edge-tts README

项目的 README,来自 github.com/rany2/edge-tts。合并为一个 markdown 文件:README.md。

edge-tts

edge-tts lets you use Microsoft Edge's online text-to-speech service from Python, or from the command line with the edge-tts and edge-playback commands.

Installation

$ uv add edge-tts          # or: pip install edge-tts

To use only the commands, install them as a tool, or run them without installing:

$ uv tool install edge-tts
$ uvx edge-tts --text "Hello, world!" --write-media hello.mp3

Command line

$ edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.srt

To play the speech back immediately, use edge-playback, which takes the same options except --write-media, --write-subtitles and --list-voices. It requires mpv, except on Windows.

$ edge-playback --text "Hello, world!"

List the available voices with --list-voices, and pick one with --voice:

$ edge-tts --voice ar-EG-SalmaNeural --text "مرحبا كيف حالك؟" --write-media hello.mp3

Adjust the speech with --rate, --volume and --pitch. Write negative values with =, so they aren't read as options:

$ edge-tts --rate=-50% --pitch=-5Hz --text "Hello, world!" --write-media hello.mp3

Run edge-tts --help for all options. Custom SSML isn't supported, because the service only accepts the SSML that Microsoft Edge itself generates.

Python

import edge_tts

edge_tts.Communicate("Hello, world!", "en-GB-SoniaNeural").save_sync("hello.mp3")

See examples/ for async usage, streaming, subtitles and voice selection.

Troubleshooting

See TROUBLESHOOTING.md for common errors, such as NoAudioReceived, and how to deal with them.

Development

uv sync                            # create the environment from uv.lock
uv run pre-commit install          # lint, format and type-check on every commit
uv run pytest

Releases are published to PyPI automatically when a GitHub release is created.

edge-tts (rany2/edge-tts)

正在搜索数据库…

这是什么?edge-tts 是一个 Python 模块和命令行工具,可以让你在代码或终端里使用 Microsoft Edge 的在线文字转语音服务,无需安装 Microsoft Edge 浏览器、Windows 系统,也不需要 API 密钥。
这是库还是命令行工具?两者都是:它是一个可以导入使用的 Python 模块,同时也提供两个命令行命令:edge-tts(生成音频或字幕)和 edge-playback(生成后立即播放)。
我该怎么安装和使用?用 'pip install edge-tts' 安装(如果只需要命令行命令,可以用 'pipx install edge-tts'),然后运行类似这样的命令:'edge-tts --text "Hello, world!" --write-media hello.mp3 --write-subtitles hello.srt'。
我需要 Microsoft Edge、Windows 或 API 密钥吗?都不需要。它直接连接 Edge 的在线文字转语音服务,所以无需 Edge 浏览器、Windows 或任何 API 密钥。如果想在非 Windows 系统上使用 edge-playback,唯一额外的依赖是 mpv 命令行播放器。
我能用自定义 SSML 来微调语音吗?不能,自定义 SSML 支持已被移除,因为微软只允许 Edge 自身能够生成的 SSML,所以你只能使用该工具提供的语速、音量、音调和语音选项。
有哪些语音和语言可用?它支持大量微软 Edge 神经网络语音,涵盖多种语言(例如阿拉伯语、阿姆哈拉语、南非荷兰语等),可以用 'edge-tts --list-voices' 查看完整列表。
它能在 Windows、macOS 和 Linux 上运行吗?可以。它是纯 Python 包,只要 Python 和 pip 能运行的地方就能用;只有 edge-playback 依赖的 mpv 在不同系统上有所不同,而 Windows 上不需要它。
我能调整语速、音量和音调吗?可以,使用 --rate、--volume 和 --pitch 参数,例如 --rate=-50% 或 --pitch=-50Hz;注意负值需要用 '=' 语法,否则会被当作单独的命令行参数解析。
它能同时生成音频和字幕吗?可以,edge-tts 命令可以在一次调用中同时写出音频文件和 .srt 字幕文件,例如 --write-media hello.mp3 --write-subtitles hello.srt。
还有哪些项目在使用 edge-tts?README 中提到了 hass-edge-tts、Podcastfy,以及一个存放语音样例的 'tts-samples' 仓库,它们都是基于 edge-tts 模块构建的项目示例。
作者
rany2
大小
2.1 MB
星标
12.6K
时长
5年
提交 · 90 天