gTTS

pnduretteMIT更新放缓

Python 库和命令行工具,调用 Google 翻译的文本转语音接口,把文字快速合成语音并保存为音频文件。

Python library and CLI tool to interface with Google Translate's text-to-speech API

v2.5.4发布于 2024-11-10 21:57 UTC2,639star389fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
pip install gTTS
gtts-cli 'hello' --output hello.mp3
硬件要求按 README 说明

README 未说明,仅依赖网络调用 Google Translate 的语音接口,无需本地 GPU 或显存

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Python 库或命令行调用谷歌翻译的语音接口,把文本转成 mp3 语音

Python 库和命令行工具,调用 Google 翻译的文本转语音接口,把文字快速合成语音并保存为音频文件。

核心能力

  • 把语音 mp3 写入文件、类文件对象或 stdout
  • 内置可定制的句子分词器,支持超长文本并保持语调
  • 支持自定义文本预处理器,可做发音纠正
  • 提供 gtts-cli 命令行和 gTTS 模块两种用法

容易踩的坑

依赖 Google Translate 未公开的语音接口,上游变更可能随时导致失效;项目与 Google 官方无关,不是 Google Cloud Text-to-Speech;需要联网才能合成语音

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2.5.4
  1. v2.5.4最新正式版2024-11-10 · 2024-11-10 21:57 UTC

    2.5.4 (2024-11-10)

    Bug Fixes

    • langs: Language added: fr-CA (French (Canada)) (#490) (defc400)
  2. v2.5.32024-08-13 · 2024-08-13 16:26 UTC
    查看更新说明

    2.5.3 (2024-08-13)

    Bug Fixes

    • langs: Languages added: pt-PT (Portuguese (Portugal)), yue (Cantonese); languages modified: pa (Punjabi (Gurmukhi)), pt (Portuguese (Brazil)) (72a7e57)
  3. v2.5.22024-07-20 · 2024-07-20 01:09 UTC
    查看更新说明

    2.5.2 (2024-07-20)

    Bug Fixes

    • langs: Languages added: am (Amharic), cy (Welsh), eu (Basque), gl (Galician), ha (Hausa), lt (Lithuanian), pa (Punjabi) (#477) (b04d6d1)
  4. v2.5.12024-01-29 · 2024-01-29 03:09 UTC
    查看更新说明

    2.5.1 (2024-01-29)

    Bug Fixes

  5. v2.5.02023-12-20 · 2023-12-20 04:16 UTC
    查看更新说明

    2.5.0 (2023-12-20)

    Features

    • Add an optional timeout parameter to gTTS that gets passed to the underlying HTTPS request (#440) (bcdb79d)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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/

    PyPI version Python versions Tests workflow codecov Commits Since PyPi Downloads Buy me a Coffee

    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