# About
A lightweight fork of the `google_speech` library, that replaces `sox` with `pygame` and removes sound effects for a lightweight and straightforward implementation.
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
**Table of Contents**
> - [About](#about)
> - [Installation](#installation)
> - [Usage](#usage)
> - [Command-Line Interface (CLI)](#command-line-interface-cli)
> - [Example: Save to File](#example-save-to-file)
> - [Python Code Examples](#python-code-examples)
> - [Example 1: Play Text-to-Speech](#example-1-play-text-to-speech)
> - [Example 2: Save Speech to a File](#example-2-save-speech-to-a-file)
> - [Setting Up Development Environment](#setting-up-development-environment)
> - [Prerequisites](#prerequisites)
> - [Steps to Set Up the Environment](#steps-to-set-up-the-environment)
> - [Building the Project](#building-the-project)
> - [Common Commands](#common-commands)
> - [Notes](#notes)
<!-- markdown-toc end -->
## Installation
```bash
pip install google_speech_pyplay
```
## Usage
The library provides both a **Command-Line Interface (CLI)** and an **API** for programmatic use.
### Command-Line Interface (CLI)
You can use the `google_speech_pyplay` command directly from the terminal:
```bash
python -m google_speech_pyplay "Hello, world!" -l en
```
Options:
- `-l`, `--lang`: Specify the language (e.g., `en` for English, `es` for Spanish).
- `-o`, `--output`: Save the speech output to an MP3 file instead of playing it.
#### Example: Save to File
Save the text-to-speech output to `output.mp3`:
```bash
python -m google_speech_pyplay "Hello, world!" -l en -o output.mp3
```
---
### Python Code Examples
Here are some examples of how to use the library in Python scripts.
#### Example 1: Play Text-to-Speech
```python
from google_speech_pyplay import Speech
# Specify the text and language
text = "Hello, world!"
language = "en"
# Create a Speech object and play the text
speech = Speech(text, language)
speech.play()
```
#### Example 2: Save Speech to a File
```python
from google_speech_pyplay import Speech
# Specify the text and language
text = "Hola, mundo!"
language = "es"
# Create a Speech object and save the speech to an MP3 file
speech = Speech(text, language)
speech.save("output.mp3")
```
## Setting Up Development Environment
To set up a fresh development environment for the `google_speech_pyplay` project, follow these steps:
### Prerequisites
1. Ensure you have Python 3.10 or newer installed.
2. Install `pip` (comes bundled with Python) and upgrade it to the latest version:
```bash
python3 -m pip install --upgrade pip
```
### Steps to Set Up the Environment
1. Clone the repository:
```bash
git clone https://github.com/KarimAziev/google_speech_pyplay.git
cd google_speech_pyplay
```
2. Create and activate a virtual environment:
```bash
python3 -m venv .venv
source .venv/bin/activate # For Linux/Mac
# or
.venv\Scripts\activate # On Windows
```
3. Upgrade core tools inside the virtual environment:
```bash
pip install --upgrade pip setuptools wheel
```
4. Install the project in editable (development) mode with all dependencies:
```bash
pip install -e ".[dev]" # Includes dev dependencies like black, pre-commit, isort
```
---
### Building the Project
To build the project for distribution, e.g., creating `.tar.gz` and `.whl` files:
1. Install the build tool:
```bash
pip install build
```
2. Build the distribution:
```bash
python -m build
```
This will generate a `dist/` directory containing the following artifacts:
- Source distribution (`google_speech_pyplay-x.y.z.tar.gz`)
- Wheel file (`google_speech_pyplay-x.y.z-py3-none-any.whl`)
You can install these locally for testing or upload them to PyPI for publishing.
---
## Common Commands
- **Clean build artifacts:**
```bash
rm -rf build dist *.egg-info
```
- **Deactivate virtual environment:**
```bash
deactivate
```
---
## Notes
- This project uses `setuptools_scm` to handle versioning, based on the Git tags of the repository. Ensure you use proper semver tags like `v1.0.0` to manage versions correctly.
- Dev dependencies (like `black`, `isort`) are automatically installed when running `pip install -e ".[dev]"`.
Raw data
{
"_id": null,
"home_page": null,
"name": "google-speech-pyplay",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "speech, pygame, audio, synthesis, voice, google, tts",
"author": null,
"author_email": "Karim Aziiev <karim.aziiev@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/fa/1b/5c7fc47b8a55a6dd0a57d73c8d75166576ae3bd4cbaef49146960a38bfb3/google_speech_pyplay-1.0.15.tar.gz",
"platform": null,
"description": "# About\n\nA lightweight fork of the `google_speech` library, that replaces `sox` with `pygame` and removes sound effects for a lightweight and straightforward implementation.\n\n<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->\n\n**Table of Contents**\n\n> - [About](#about)\n> - [Installation](#installation)\n> - [Usage](#usage)\n> - [Command-Line Interface (CLI)](#command-line-interface-cli)\n> - [Example: Save to File](#example-save-to-file)\n> - [Python Code Examples](#python-code-examples)\n> - [Example 1: Play Text-to-Speech](#example-1-play-text-to-speech)\n> - [Example 2: Save Speech to a File](#example-2-save-speech-to-a-file)\n> - [Setting Up Development Environment](#setting-up-development-environment)\n> - [Prerequisites](#prerequisites)\n> - [Steps to Set Up the Environment](#steps-to-set-up-the-environment)\n> - [Building the Project](#building-the-project)\n> - [Common Commands](#common-commands)\n> - [Notes](#notes)\n\n<!-- markdown-toc end -->\n\n## Installation\n\n```bash\npip install google_speech_pyplay\n```\n\n## Usage\n\nThe library provides both a **Command-Line Interface (CLI)** and an **API** for programmatic use.\n\n### Command-Line Interface (CLI)\n\nYou can use the `google_speech_pyplay` command directly from the terminal:\n\n```bash\npython -m google_speech_pyplay \"Hello, world!\" -l en\n```\n\nOptions:\n\n- `-l`, `--lang`: Specify the language (e.g., `en` for English, `es` for Spanish).\n- `-o`, `--output`: Save the speech output to an MP3 file instead of playing it.\n\n#### Example: Save to File\n\nSave the text-to-speech output to `output.mp3`:\n\n```bash\npython -m google_speech_pyplay \"Hello, world!\" -l en -o output.mp3\n```\n\n---\n\n### Python Code Examples\n\nHere are some examples of how to use the library in Python scripts.\n\n#### Example 1: Play Text-to-Speech\n\n```python\nfrom google_speech_pyplay import Speech\n\n# Specify the text and language\ntext = \"Hello, world!\"\nlanguage = \"en\"\n\n# Create a Speech object and play the text\nspeech = Speech(text, language)\nspeech.play()\n```\n\n#### Example 2: Save Speech to a File\n\n```python\nfrom google_speech_pyplay import Speech\n\n# Specify the text and language\ntext = \"Hola, mundo!\"\nlanguage = \"es\"\n\n# Create a Speech object and save the speech to an MP3 file\nspeech = Speech(text, language)\nspeech.save(\"output.mp3\")\n```\n\n## Setting Up Development Environment\n\nTo set up a fresh development environment for the `google_speech_pyplay` project, follow these steps:\n\n### Prerequisites\n\n1. Ensure you have Python 3.10 or newer installed.\n2. Install `pip` (comes bundled with Python) and upgrade it to the latest version:\n ```bash\n python3 -m pip install --upgrade pip\n ```\n\n### Steps to Set Up the Environment\n\n1. Clone the repository:\n\n ```bash\n git clone https://github.com/KarimAziev/google_speech_pyplay.git\n cd google_speech_pyplay\n ```\n\n2. Create and activate a virtual environment:\n\n ```bash\n python3 -m venv .venv\n source .venv/bin/activate # For Linux/Mac\n # or\n .venv\\Scripts\\activate # On Windows\n ```\n\n3. Upgrade core tools inside the virtual environment:\n\n ```bash\n pip install --upgrade pip setuptools wheel\n ```\n\n4. Install the project in editable (development) mode with all dependencies:\n ```bash\n pip install -e \".[dev]\" # Includes dev dependencies like black, pre-commit, isort\n ```\n\n---\n\n### Building the Project\n\nTo build the project for distribution, e.g., creating `.tar.gz` and `.whl` files:\n\n1. Install the build tool:\n\n ```bash\n pip install build\n ```\n\n2. Build the distribution:\n ```bash\n python -m build\n ```\n\nThis will generate a `dist/` directory containing the following artifacts:\n\n- Source distribution (`google_speech_pyplay-x.y.z.tar.gz`)\n- Wheel file (`google_speech_pyplay-x.y.z-py3-none-any.whl`)\n\nYou can install these locally for testing or upload them to PyPI for publishing.\n\n---\n\n## Common Commands\n\n- **Clean build artifacts:**\n ```bash\n rm -rf build dist *.egg-info\n ```\n- **Deactivate virtual environment:**\n ```bash\n deactivate\n ```\n\n---\n\n## Notes\n\n- This project uses `setuptools_scm` to handle versioning, based on the Git tags of the repository. Ensure you use proper semver tags like `v1.0.0` to manage versions correctly.\n- Dev dependencies (like `black`, `isort`) are automatically installed when running `pip install -e \".[dev]\"`.\n",
"bugtrack_url": null,
"license": "GNU",
"summary": "Text-to-speech synthesis using the Google Translate TTS API and pygame.",
"version": "1.0.15",
"project_urls": null,
"split_keywords": [
"speech",
" pygame",
" audio",
" synthesis",
" voice",
" google",
" tts"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ee3c7af074d635347b0355469a363bc2a95bcf7ebc18d1f269ad1fa82d0c3100",
"md5": "17f31d7407d323aac893727e62e0f56d",
"sha256": "cf58e81974bf9720f2ea3f41463bcfa2bf3d5491ebf806f350123c93ece740c6"
},
"downloads": -1,
"filename": "google_speech_pyplay-1.0.15-py3-none-any.whl",
"has_sig": false,
"md5_digest": "17f31d7407d323aac893727e62e0f56d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 25846,
"upload_time": "2025-09-05T14:43:32",
"upload_time_iso_8601": "2025-09-05T14:43:32.281342Z",
"url": "https://files.pythonhosted.org/packages/ee/3c/7af074d635347b0355469a363bc2a95bcf7ebc18d1f269ad1fa82d0c3100/google_speech_pyplay-1.0.15-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "fa1b5c7fc47b8a55a6dd0a57d73c8d75166576ae3bd4cbaef49146960a38bfb3",
"md5": "9bd2ccee551e6638ea2a2ad8871f3b1f",
"sha256": "44dbe3bed7935685224bc984fa8261018bcf1cc68c5a92a123e124caf5dc9ef9"
},
"downloads": -1,
"filename": "google_speech_pyplay-1.0.15.tar.gz",
"has_sig": false,
"md5_digest": "9bd2ccee551e6638ea2a2ad8871f3b1f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 28730,
"upload_time": "2025-09-05T14:43:33",
"upload_time_iso_8601": "2025-09-05T14:43:33.119592Z",
"url": "https://files.pythonhosted.org/packages/fa/1b/5c7fc47b8a55a6dd0a57d73c8d75166576ae3bd4cbaef49146960a38bfb3/google_speech_pyplay-1.0.15.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-05 14:43:33",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "google-speech-pyplay"
}