silero-tts


Namesilero-tts JSON
Version 0.0.5 PyPI version JSON
download
home_pageNone
SummaryScript over the official Silero so that it can be conveniently and quickly used from the code or from the console
upload_time2024-10-18 17:27:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Silero TTS

**README is available in the following languages:**

[![EN](https://img.shields.io/badge/EN-blue.svg)](https://github.com/daswer123/silero-tts-enhanced)
[![RU](https://img.shields.io/badge/RU-red.svg)](https://github.com/daswer123/silero-tts-enhanced/blob/main/README_RU.MD)

Silero TTS is a Python library that provides an easy way to synthesize speech from text using various Silero TTS models, languages, and speakers. It can be used as a standalone script or integrated into your own Python projects.

## Features

- Support for multiple languages and models
- Automatic downloading of the latest model configuration file
- Text preprocessing and transliteration
- Batch processing of text files
- Detailed logging with loguru
- Progress tracking with tqdm
- Customizable options for sample rate, device, and more
- Can be used as a standalone script or integrated into Python code

## Installation

### Auto ( Recomended )
 
   ```
   pip install silero-tts
   ```

### Manualy
1. Clone the repository:
   ```
   git clone https://github.com/daswer123/silero-tts-enhanced
   ```

2. Install the required dependencies:
   ```
   pip install -r requirements.txt
   ```

## Usage

### As a Standalone Script

You can use Silero TTS as a standalone script to synthesize speech from text files or directories containing text files.

```
python -m silero_tts [options]
```

#### Options

- `--list-models`: List available models
- `--list-speakers`: List available speakers for a model
- `--language LANGUAGE`: Specify the language code (required)
- `--model MODEL`: Specify the model ID (default: latest version for the language)
- `--speaker SPEAKER`: Specify the speaker name (default: first available speaker for the model)
- `--sample-rate SAMPLE_RATE`: Specify the sample rate (default: 48000)
- `--device DEVICE`: Specify the device to use (default: cpu)
- `--text TEXT`: Specify the text to synthesize
- `--input-file INPUT_FILE`: Specify the input text file to synthesize
- `--input-dir INPUT_DIR`: Specify the input directory with text files to synthesize
- `--output-file OUTPUT_FILE`: Specify the output audio file (default: output.wav)
- `--output-dir OUTPUT_DIR`: Specify the output directory for synthesized audio files (default: output)
- `--log-level INFO` : Specify log-level, you can turn off use NONE value (default: INFO)

#### Examples

1. Synthesize speech from a text:
   ```
   python silero_tts.py --language ru --text "Привет, мир!"
   ```

2. Synthesize speech from a text file:
   ```
   python silero_tts.py --language en --input-file input.txt --output-file output.wav
   ```

3. Synthesize speech from multiple text files in a directory:
   ```
   python silero_tts.py --language es --input-dir texts --output-dir audio
   ```

### As a Python Library

You can also integrate Silero TTS into your own Python projects by importing the `SileroTTS` class and using its methods.

```python
from silero_tts.silero_tts import SileroTTS

# Get available models
models = SileroTTS.get_available_models()
print("Available models:", models)

# Get available languages
languages = SileroTTS.get_available_languages()
print("Available languages:", languages)

# Get the latest model for a specific language
latest_model = SileroTTS.get_latest_model('ru')
print("Latest model for Russian:", latest_model)

# Get available sample rates for a specific model and language
sample_rates = SileroTTS.get_available_sample_rates_static('ru', latest_model)
print("Available sample rates for the latest Russian model:", sample_rates)

# Initialize the TTS object
tts = SileroTTS(model_id='v3_en', language='en', speaker='en_2', sample_rate=48000, device='cpu')

# Synthesize speech from text
text = "Hello world!"
tts.tts(text, 'output.wav')

# Synthesize speech from a text file
# tts.from_file('input.txt', 'output.wav')

# Get available speakers for the current model
speakers = tts.get_available_speakers()
print("Available speakers for the current model:", speakers)

# Change the language
tts.change_language('en')
print("Language changed to:", tts.language)
print("New model ID:", tts.model_id)
print("New available speakers:", tts.get_available_speakers())

# Change the model
tts.change_model('v3_en')
print("Model changed to:", tts.model_id)
print("New available speakers:", tts.get_available_speakers())

# Change the speaker
tts.change_speaker('en_0')
print("Speaker changed to:", tts.speaker)

# Change the sample rate
tts.change_sample_rate(24000)
print("Sample rate changed to:", tts.sample_rate)
```

## CLI Features

The Silero TTS CLI provides the following features:

- **Language Support**: Specify the language code using the `--language` flag to synthesize speech in the desired language.
- **Model Selection**: Choose a specific model using the `--model` flag or let the CLI automatically select the latest model for the specified language.
- **Speaker Selection**: Select a speaker using the `--speaker` flag or use the default speaker for the chosen model.
- **Sample Rate**: Customize the sample rate of the synthesized speech using the `--sample-rate` flag.
- **Device**: Specify the device (CPU or GPU) to use for synthesis using the `--device` flag.
- **Text Input**: Provide the text to synthesize directly using the `--text` flag or specify an input text file using the `--input-file` flag.
- **Batch Processing**: Process multiple text files in a directory using the `--input-dir` flag.
- **Output**: Specify the output audio file using the `--output-file` flag or the output directory for batch processing using the `--output-dir` flag.
- **Model Listing**: List all available models using the `--list-models` flag.
- **Speaker Listing**: List all available speakers for a specific model using the `--list-speakers` flag.

## Supported Languages

- Russian (ru)
- English (en)
- German (de)
- Spanish (es)
- French (fr)
- Bashkir (ba)
- Kalmyk (xal)
- Tatar (tt)
- Uzbek (uz)
- Ukrainian (ua)
- Indic (indic)
- Cyrillic (cyrillic)

## License

This project is licensed under the [MIT License](LICENSE).

## Acknowledgements

- [Silero Models](https://github.com/snakers4/silero-models) for providing the TTS models
- [silero_tts_standalone](https://github.com/S-trace/silero_tts_standalone) this library inspired me to create this project.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "silero-tts",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "daswer123 <daswerq123@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/4f/02/262a09a8bd66c6fd4f8e9bd8fa7b17c7dda2d475fe197ab174bca175f528/silero_tts-0.0.5.tar.gz",
    "platform": null,
    "description": "# Silero TTS\n\n**README is available in the following languages:**\n\n[![EN](https://img.shields.io/badge/EN-blue.svg)](https://github.com/daswer123/silero-tts-enhanced)\n[![RU](https://img.shields.io/badge/RU-red.svg)](https://github.com/daswer123/silero-tts-enhanced/blob/main/README_RU.MD)\n\nSilero TTS is a Python library that provides an easy way to synthesize speech from text using various Silero TTS models, languages, and speakers. It can be used as a standalone script or integrated into your own Python projects.\n\n## Features\n\n- Support for multiple languages and models\n- Automatic downloading of the latest model configuration file\n- Text preprocessing and transliteration\n- Batch processing of text files\n- Detailed logging with loguru\n- Progress tracking with tqdm\n- Customizable options for sample rate, device, and more\n- Can be used as a standalone script or integrated into Python code\n\n## Installation\n\n### Auto ( Recomended )\n \n   ```\n   pip install silero-tts\n   ```\n\n### Manualy\n1. Clone the repository:\n   ```\n   git clone https://github.com/daswer123/silero-tts-enhanced\n   ```\n\n2. Install the required dependencies:\n   ```\n   pip install -r requirements.txt\n   ```\n\n## Usage\n\n### As a Standalone Script\n\nYou can use Silero TTS as a standalone script to synthesize speech from text files or directories containing text files.\n\n```\npython -m silero_tts [options]\n```\n\n#### Options\n\n- `--list-models`: List available models\n- `--list-speakers`: List available speakers for a model\n- `--language LANGUAGE`: Specify the language code (required)\n- `--model MODEL`: Specify the model ID (default: latest version for the language)\n- `--speaker SPEAKER`: Specify the speaker name (default: first available speaker for the model)\n- `--sample-rate SAMPLE_RATE`: Specify the sample rate (default: 48000)\n- `--device DEVICE`: Specify the device to use (default: cpu)\n- `--text TEXT`: Specify the text to synthesize\n- `--input-file INPUT_FILE`: Specify the input text file to synthesize\n- `--input-dir INPUT_DIR`: Specify the input directory with text files to synthesize\n- `--output-file OUTPUT_FILE`: Specify the output audio file (default: output.wav)\n- `--output-dir OUTPUT_DIR`: Specify the output directory for synthesized audio files (default: output)\n- `--log-level INFO` : Specify log-level, you can turn off use NONE value (default: INFO)\n\n#### Examples\n\n1. Synthesize speech from a text:\n   ```\n   python silero_tts.py --language ru --text \"\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0438\u0440!\"\n   ```\n\n2. Synthesize speech from a text file:\n   ```\n   python silero_tts.py --language en --input-file input.txt --output-file output.wav\n   ```\n\n3. Synthesize speech from multiple text files in a directory:\n   ```\n   python silero_tts.py --language es --input-dir texts --output-dir audio\n   ```\n\n### As a Python Library\n\nYou can also integrate Silero TTS into your own Python projects by importing the `SileroTTS` class and using its methods.\n\n```python\nfrom silero_tts.silero_tts import SileroTTS\n\n# Get available models\nmodels = SileroTTS.get_available_models()\nprint(\"Available models:\", models)\n\n# Get available languages\nlanguages = SileroTTS.get_available_languages()\nprint(\"Available languages:\", languages)\n\n# Get the latest model for a specific language\nlatest_model = SileroTTS.get_latest_model('ru')\nprint(\"Latest model for Russian:\", latest_model)\n\n# Get available sample rates for a specific model and language\nsample_rates = SileroTTS.get_available_sample_rates_static('ru', latest_model)\nprint(\"Available sample rates for the latest Russian model:\", sample_rates)\n\n# Initialize the TTS object\ntts = SileroTTS(model_id='v3_en', language='en', speaker='en_2', sample_rate=48000, device='cpu')\n\n# Synthesize speech from text\ntext = \"Hello world!\"\ntts.tts(text, 'output.wav')\n\n# Synthesize speech from a text file\n# tts.from_file('input.txt', 'output.wav')\n\n# Get available speakers for the current model\nspeakers = tts.get_available_speakers()\nprint(\"Available speakers for the current model:\", speakers)\n\n# Change the language\ntts.change_language('en')\nprint(\"Language changed to:\", tts.language)\nprint(\"New model ID:\", tts.model_id)\nprint(\"New available speakers:\", tts.get_available_speakers())\n\n# Change the model\ntts.change_model('v3_en')\nprint(\"Model changed to:\", tts.model_id)\nprint(\"New available speakers:\", tts.get_available_speakers())\n\n# Change the speaker\ntts.change_speaker('en_0')\nprint(\"Speaker changed to:\", tts.speaker)\n\n# Change the sample rate\ntts.change_sample_rate(24000)\nprint(\"Sample rate changed to:\", tts.sample_rate)\n```\n\n## CLI Features\n\nThe Silero TTS CLI provides the following features:\n\n- **Language Support**: Specify the language code using the `--language` flag to synthesize speech in the desired language.\n- **Model Selection**: Choose a specific model using the `--model` flag or let the CLI automatically select the latest model for the specified language.\n- **Speaker Selection**: Select a speaker using the `--speaker` flag or use the default speaker for the chosen model.\n- **Sample Rate**: Customize the sample rate of the synthesized speech using the `--sample-rate` flag.\n- **Device**: Specify the device (CPU or GPU) to use for synthesis using the `--device` flag.\n- **Text Input**: Provide the text to synthesize directly using the `--text` flag or specify an input text file using the `--input-file` flag.\n- **Batch Processing**: Process multiple text files in a directory using the `--input-dir` flag.\n- **Output**: Specify the output audio file using the `--output-file` flag or the output directory for batch processing using the `--output-dir` flag.\n- **Model Listing**: List all available models using the `--list-models` flag.\n- **Speaker Listing**: List all available speakers for a specific model using the `--list-speakers` flag.\n\n## Supported Languages\n\n- Russian (ru)\n- English (en)\n- German (de)\n- Spanish (es)\n- French (fr)\n- Bashkir (ba)\n- Kalmyk (xal)\n- Tatar (tt)\n- Uzbek (uz)\n- Ukrainian (ua)\n- Indic (indic)\n- Cyrillic (cyrillic)\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n## Acknowledgements\n\n- [Silero Models](https://github.com/snakers4/silero-models) for providing the TTS models\n- [silero_tts_standalone](https://github.com/S-trace/silero_tts_standalone) this library inspired me to create this project.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Script over the official Silero so that it can be conveniently and quickly used from the code or from the console",
    "version": "0.0.5",
    "project_urls": {
        "Bug Tracker": "https://github.com/daswer123/silero_cli/issues",
        "Homepage": "https://github.com/daswer123/silero_cli"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b8d724cf89bcd6c369fdf1c364c8f9670eb855232b9aa7241c62faadcf2edcf0",
                "md5": "ac30ff23a633507c75c4591de919db5a",
                "sha256": "e33812108c8861aeedccc7942721d5c300196a9e558f736657518e453b1bdb05"
            },
            "downloads": -1,
            "filename": "silero_tts-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ac30ff23a633507c75c4591de919db5a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 13224,
            "upload_time": "2024-10-18T17:27:27",
            "upload_time_iso_8601": "2024-10-18T17:27:27.631551Z",
            "url": "https://files.pythonhosted.org/packages/b8/d7/24cf89bcd6c369fdf1c364c8f9670eb855232b9aa7241c62faadcf2edcf0/silero_tts-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4f02262a09a8bd66c6fd4f8e9bd8fa7b17c7dda2d475fe197ab174bca175f528",
                "md5": "fecf7a57373ab7d45e16783ca129c28d",
                "sha256": "da72506036b2d5cc0eef3eaf946d437a28070315f6d45d4ba4c9b8dd50af242d"
            },
            "downloads": -1,
            "filename": "silero_tts-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "fecf7a57373ab7d45e16783ca129c28d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 17607,
            "upload_time": "2024-10-18T17:27:29",
            "upload_time_iso_8601": "2024-10-18T17:27:29.283409Z",
            "url": "https://files.pythonhosted.org/packages/4f/02/262a09a8bd66c6fd4f8e9bd8fa7b17c7dda2d475fe197ab174bca175f528/silero_tts-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-18 17:27:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "daswer123",
    "github_project": "silero_cli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "silero-tts"
}
        
Elapsed time: 0.67584s