依赖 Google Translate 未公开的语音接口,上游变更可能随时导致失效;项目与 Google 官方无关,不是 Google Cloud Text-to-Speech;需要联网才能合成语音
pip install gTTS
gtts-cli 'hello' --output hello.mp3README 未说明,仅依赖网络调用 Google Translate 的语音接口,无需本地 GPU 或显存
用 Python 库或命令行调用谷歌翻译的语音接口,把文本转成 mp3 语音
Python 库和命令行工具,调用 Google 翻译的文本转语音接口,把文字快速合成语音并保存为音频文件。
核心能力
- 把语音 mp3 写入文件、类文件对象或 stdout
- 内置可定制的句子分词器,支持超长文本并保持语调
- 支持自定义文本预处理器,可做发音纠正
- 提供 gtts-cli 命令行和 gTTS 模块两种用法
容易踩的坑
- v2.5.4最新正式版2024-11-10 · 2024-11-10 21:57 UTC
- v2.5.32024-08-13 · 2024-08-13 16:26 UTC
- v2.5.22024-07-20 · 2024-07-20 01:09 UTC
- v2.5.12024-01-29 · 2024-01-29 03:09 UTC
- v2.5.02023-12-20 · 2023-12-20 04:16 UTC
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
gTTS
gTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate's text-to-speech API.
Write spoken mp3 data to a file, a file-like object (bytestring) for further audio manipulation, or stdout.
https://gtts.readthedocs.io/
Features
- Customizable speech-specific sentence tokenizer that allows for unlimited lengths of text to be read, all while keeping proper intonation, abbreviations, decimals and more;
- Customizable text pre-processors which can, for example, provide pronunciation corrections;
Installation
$ pip install gTTS
Quickstart
Command Line:
$ gtts-cli 'hello' --output hello.mp3
Module:
>>> from gtts import gTTS
>>> tts = gTTS('hello')
>>> tts.save('hello.mp3')
See https://gtts.readthedocs.io/ for documentation and examples.
Disclaimer
This project is not affiliated with Google or Google Cloud. Breaking upstream changes can occur without notice. This project is leveraging the undocumented Google Translate speech functionality and is different from Google Cloud Text-to-Speech.
Project
Licence
The MIT License (MIT) Copyright © 2014-2024 Pierre Nicolas Durette & Contributors