tts-joinery


Nametts-joinery JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryAutomate chunking long texts to produce a single audio file from text-to-speech APIs
upload_time2024-08-16 17:31:07
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 Adrien Delessert Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords openai tts ai cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tts-joinery

tts-joinery is a Python library and CLI tool to work around length limitations in text-to-speech APIs.

Since currently-popular APIs are limited to 4096 characters, this library will:

-   Chunk the input text into sentences using the [NLTK Punkt module](https://www.nltk.org/api/nltk.tokenize.punkt.html)
-   Run each chunk through the TTS API
-   Join together the resulting output to produce a single MP3 file

Currently only the OpenAI API is supported, with the intent to add more in the future.

## Installation

```bash
pip install tts-joinery
```

or use `pipx` to install as a standalone tool.

**Requires ffmpeg** for the audio file processing.

Installation may vary depending on your system. On Linux you can use your system package manager. On Mac `brew install ffmpeg` should work.

## Usage

### Command-Line Interface (CLI)

The CLI expects to find an OpenAI API Key in a `OPENAI_API_KEY` environment variable, or in a .env file.

#### Syntax

```
ttsjoin [OPTIONS]
```

#### Options

```
--input-file FILENAME   Plaintext file to process into speech, otherwise stdin
--output-file FILENAME  MP3 result, otherwise stdout
--model TEXT            Slug of the text-to-speech model to be used
--service TEXT          API service (currently only supports openai)
--voice TEXT            Slug of the voice to be used
--no-cache BOOLEAN      Disable caching
--help                  Show this message and exit.
```

#### Examples

1. Using an input file and specifying an output file:

```bash
ttsjoin --input-file input.txt --output-file output.mp3 --model tts-1 --service openai --voice onyx
```

2. Using stdin and stdout with default options:

```bash
echo "Your text to be processed" | ttsjoin > output.mp3
```

3. Each chunk of text is cached for performance when the same text multiple times, this can be disabled:

```bash
ttsjoin --input-file input.txt --output-file output.mp3 --no-cache
```

### Python Library

You can also use tts-joinery as part of your Python project:

```python
from joinery.op import JoinOp
from joinery.api.openai import OpenAIApi

tts = JoinOp(
    text='This is only a test!',
    api=OpenAIApi(
        model='tts-1-hd',
        voice='onyx',
        api_key=OPENAI_API_KEY,
    ),
)

tts.process_to_file('output.mp3')
```

## Contributing

Contributions welcome, particularly other TTS APIs, check the issues beforehand and feel free to open a PR. Code is formatted with Black.

## License

This project is licensed under the MIT License.

Copyright 2024, Adrien Delessert

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tts-joinery",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "openai, tts, ai, cli",
    "author": null,
    "author_email": "Adrien Delessert <adrien@delessert.com>",
    "download_url": "https://files.pythonhosted.org/packages/ee/2f/b45ca9d4162958e4f273bb85d18ea269fba80a6c060f2331c44ee02a0587/tts_joinery-1.0.1.tar.gz",
    "platform": null,
    "description": "# tts-joinery\n\ntts-joinery is a Python library and CLI tool to work around length limitations in text-to-speech APIs.\n\nSince currently-popular APIs are limited to 4096 characters, this library will:\n\n-   Chunk the input text into sentences using the [NLTK Punkt module](https://www.nltk.org/api/nltk.tokenize.punkt.html)\n-   Run each chunk through the TTS API\n-   Join together the resulting output to produce a single MP3 file\n\nCurrently only the OpenAI API is supported, with the intent to add more in the future.\n\n## Installation\n\n```bash\npip install tts-joinery\n```\n\nor use `pipx` to install as a standalone tool.\n\n**Requires ffmpeg** for the audio file processing.\n\nInstallation may vary depending on your system. On Linux you can use your system package manager. On Mac `brew install ffmpeg` should work.\n\n## Usage\n\n### Command-Line Interface (CLI)\n\nThe CLI expects to find an OpenAI API Key in a `OPENAI_API_KEY` environment variable, or in a .env file.\n\n#### Syntax\n\n```\nttsjoin [OPTIONS]\n```\n\n#### Options\n\n```\n--input-file FILENAME   Plaintext file to process into speech, otherwise stdin\n--output-file FILENAME  MP3 result, otherwise stdout\n--model TEXT            Slug of the text-to-speech model to be used\n--service TEXT          API service (currently only supports openai)\n--voice TEXT            Slug of the voice to be used\n--no-cache BOOLEAN      Disable caching\n--help                  Show this message and exit.\n```\n\n#### Examples\n\n1. Using an input file and specifying an output file:\n\n```bash\nttsjoin --input-file input.txt --output-file output.mp3 --model tts-1 --service openai --voice onyx\n```\n\n2. Using stdin and stdout with default options:\n\n```bash\necho \"Your text to be processed\" | ttsjoin > output.mp3\n```\n\n3. Each chunk of text is cached for performance when the same text multiple times, this can be disabled:\n\n```bash\nttsjoin --input-file input.txt --output-file output.mp3 --no-cache\n```\n\n### Python Library\n\nYou can also use tts-joinery as part of your Python project:\n\n```python\nfrom joinery.op import JoinOp\nfrom joinery.api.openai import OpenAIApi\n\ntts = JoinOp(\n    text='This is only a test!',\n    api=OpenAIApi(\n        model='tts-1-hd',\n        voice='onyx',\n        api_key=OPENAI_API_KEY,\n    ),\n)\n\ntts.process_to_file('output.mp3')\n```\n\n## Contributing\n\nContributions welcome, particularly other TTS APIs, check the issues beforehand and feel free to open a PR. Code is formatted with Black.\n\n## License\n\nThis project is licensed under the MIT License.\n\nCopyright 2024, Adrien Delessert\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Adrien Delessert  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Automate chunking long texts to produce a single audio file from text-to-speech APIs",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/drien/tts-joinery"
    },
    "split_keywords": [
        "openai",
        " tts",
        " ai",
        " cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5840e587e0638b61444e9f6180710f42f1fca14dbd1cd945f753ac46d56bcb62",
                "md5": "72dc29b768b8a6b0b69277e9c6948006",
                "sha256": "07c0e5d01d66ddf7bfc9f1da1c1f475cade944d877aaa5122fe2c4f6c739b2d5"
            },
            "downloads": -1,
            "filename": "tts_joinery-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "72dc29b768b8a6b0b69277e9c6948006",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8061,
            "upload_time": "2024-08-16T17:31:05",
            "upload_time_iso_8601": "2024-08-16T17:31:05.468296Z",
            "url": "https://files.pythonhosted.org/packages/58/40/e587e0638b61444e9f6180710f42f1fca14dbd1cd945f753ac46d56bcb62/tts_joinery-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ee2fb45ca9d4162958e4f273bb85d18ea269fba80a6c060f2331c44ee02a0587",
                "md5": "983e1bc3571a70dc9a1971aa4f373b9c",
                "sha256": "fd8b0fab355f6404a95e26e1911f3ea410bde76b4b033d975d3b4c179e5606e8"
            },
            "downloads": -1,
            "filename": "tts_joinery-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "983e1bc3571a70dc9a1971aa4f373b9c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7682,
            "upload_time": "2024-08-16T17:31:07",
            "upload_time_iso_8601": "2024-08-16T17:31:07.428350Z",
            "url": "https://files.pythonhosted.org/packages/ee/2f/b45ca9d4162958e4f273bb85d18ea269fba80a6c060f2331c44ee02a0587/tts_joinery-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-16 17:31:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "drien",
    "github_project": "tts-joinery",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tts-joinery"
}
        
Elapsed time: 1.55460s