ospeak


Nameospeak JSON
Version 0.3 PyPI version JSON
download
home_page
SummaryCLI tool for running text through OpenAI Text to speech
upload_time2023-12-13 06:13:17
maintainer
docs_urlNone
authorSimon Willison
requires_python>=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ospeak

[![PyPI](https://img.shields.io/pypi/v/ospeak.svg)](https://pypi.org/project/ospeak/)
[![Changelog](https://img.shields.io/github/v/release/simonw/ospeak?include_prereleases&label=changelog)](https://github.com/simonw/ospeak/releases)
[![Tests](https://github.com/simonw/ospeak/workflows/Test/badge.svg)](https://github.com/simonw/ospeak/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/ospeak/blob/master/LICENSE)

CLI tool for running text through the [OpenAI Text to speech](https://platform.openai.com/docs/guides/text-to-speech) API and speaking or saving the result

See [ospeak: a CLI tool for speaking text in the terminal via OpenAI](https://simonwillison.net/2023/Nov/7/ospeak/) for background on this project.

## Installation

Install this tool using `pipx`:
```bash
pipx install ospeak
```
Note, on MacOS there's a [broken dependency](https://github.com/simonw/ospeak/issues/4) with Python 3.12 so instead run:
```bash 
pipx install --python /path/to/python3.11 ospeak
```

This tool also depends on `ffmpeg`. You can install that on macOS using [Homebrew](https://brew.sh/) like this:
```bash
brew install ffmpeg
```
Note that `ospeak` has dependencies that are currently incompatible with [LLM](https://llm.datasette.io) (see [this issue](https://github.com/simonw/llm/issues/325)) so the two tools need to be installed in different virtual environments, hence the recommendation to use [pipx](https://pypa.github.io/pipx/).

## Usage

To get your computer to say something, run:
```bash
ospeak "Hello there"
```
You will need an OpenAI API key. You can set that as an environment variable:
```bash
export OPENAI_API_KEY="..."
```
Or you can pass it using `--token`:
```bash
ospeak --token "..." "Hello there"
```
You can pipe content into the tool:
```bash
echo "Hello there" | ospeak
```
Use `-v/--voice VOICE` to select a voice. The default is `alloy`. The other options are:

- `echo`
- `fable`
- `onyx`
- `nova`
- `shimmer`

You can pass `-v all` to hear all of the voices, each with the name of the voice spoken first.
```bash
ospeak "This is my voice" -v all
```
The `-m/--model` option can be used to select a different model. The default is `tts-1`. Use `-m tts-1-hd` for a higher quality model that takes slightly longer to generate audio:
```bash
ospeak "This is higher quality" -m tts-1-hd
```
To adjust the speed, pass `-x/--speed` with a value between 0.25 and 4 (the default is 1.0):
```bash
ospeak "This is my fast voice" -x 2
```
To write the audio to a file, pass `-o/--output` with a filename ending in either `.mp3` or `.wav`:
```bash
ospeak "This is my voice" -o voice.mp3
```
This will not speak out loud. If you want it to also speak, add the `-s/--speak` option:
```bash
ospeak "This is my voice" -o voice.mp3 -s
```

## ospeak --help

<!-- [[[cog
import cog
from ospeak import cli
from click.testing import CliRunner
runner = CliRunner()
result = runner.invoke(cli.cli, ["--help"])
help = result.output.replace("Usage: cli", "Usage: ospeak")
cog.out(
    "```\n{}\n```".format(help)
)
]]] -->
```
Usage: ospeak [OPTIONS] [TEXT]

  CLI tool for running text through OpenAI Text to speech

  Set the OPENAI_API_KEY environment variable to your OpenAI API key to avoid
  using the --token option every time.

  Example usage:

      ospeak "Everyone deserves a pelican" --voice alloy -x 1.5

Options:
  --version                       Show the version and exit.
  -v, --voice [alloy|echo|fable|onyx|nova|shimmer|all]
                                  Voice to use
  -m, --model TEXT                Model to use - defaults to tts-1
  -o, --output FILE               Save audio to this file on disk
  -x, --speed FLOAT RANGE         Speed of the voice  [0.25<=x<=4.0]
  -s, --speak                     Speak the text even when saving to a file
  --token TEXT                    OpenAI API key
  --help                          Show this message and exit.

```
<!-- [[[end]]] -->

## Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:
```bash
cd ospeak
python -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
pip install -e '.[test]'
```
To run the tests:
```bash
pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ospeak",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Simon Willison",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/ad/a8/4b0b0c962bfe35076171790012826fda8ce4e78ee480bc5cc9babc1111a9/ospeak-0.3.tar.gz",
    "platform": null,
    "description": "# ospeak\n\n[![PyPI](https://img.shields.io/pypi/v/ospeak.svg)](https://pypi.org/project/ospeak/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/ospeak?include_prereleases&label=changelog)](https://github.com/simonw/ospeak/releases)\n[![Tests](https://github.com/simonw/ospeak/workflows/Test/badge.svg)](https://github.com/simonw/ospeak/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/ospeak/blob/master/LICENSE)\n\nCLI tool for running text through the [OpenAI Text to speech](https://platform.openai.com/docs/guides/text-to-speech) API and speaking or saving the result\n\nSee [ospeak: a CLI tool for speaking text in the terminal via OpenAI](https://simonwillison.net/2023/Nov/7/ospeak/) for background on this project.\n\n## Installation\n\nInstall this tool using `pipx`:\n```bash\npipx install ospeak\n```\nNote, on MacOS there's a [broken dependency](https://github.com/simonw/ospeak/issues/4) with Python 3.12 so instead run:\n```bash \npipx install --python /path/to/python3.11 ospeak\n```\n\nThis tool also depends on `ffmpeg`. You can install that on macOS using [Homebrew](https://brew.sh/) like this:\n```bash\nbrew install ffmpeg\n```\nNote that `ospeak` has dependencies that are currently incompatible with [LLM](https://llm.datasette.io) (see [this issue](https://github.com/simonw/llm/issues/325)) so the two tools need to be installed in different virtual environments, hence the recommendation to use [pipx](https://pypa.github.io/pipx/).\n\n## Usage\n\nTo get your computer to say something, run:\n```bash\nospeak \"Hello there\"\n```\nYou will need an OpenAI API key. You can set that as an environment variable:\n```bash\nexport OPENAI_API_KEY=\"...\"\n```\nOr you can pass it using `--token`:\n```bash\nospeak --token \"...\" \"Hello there\"\n```\nYou can pipe content into the tool:\n```bash\necho \"Hello there\" | ospeak\n```\nUse `-v/--voice VOICE` to select a voice. The default is `alloy`. The other options are:\n\n- `echo`\n- `fable`\n- `onyx`\n- `nova`\n- `shimmer`\n\nYou can pass `-v all` to hear all of the voices, each with the name of the voice spoken first.\n```bash\nospeak \"This is my voice\" -v all\n```\nThe `-m/--model` option can be used to select a different model. The default is `tts-1`. Use `-m tts-1-hd` for a higher quality model that takes slightly longer to generate audio:\n```bash\nospeak \"This is higher quality\" -m tts-1-hd\n```\nTo adjust the speed, pass `-x/--speed` with a value between 0.25 and 4 (the default is 1.0):\n```bash\nospeak \"This is my fast voice\" -x 2\n```\nTo write the audio to a file, pass `-o/--output` with a filename ending in either `.mp3` or `.wav`:\n```bash\nospeak \"This is my voice\" -o voice.mp3\n```\nThis will not speak out loud. If you want it to also speak, add the `-s/--speak` option:\n```bash\nospeak \"This is my voice\" -o voice.mp3 -s\n```\n\n## ospeak --help\n\n<!-- [[[cog\nimport cog\nfrom ospeak import cli\nfrom click.testing import CliRunner\nrunner = CliRunner()\nresult = runner.invoke(cli.cli, [\"--help\"])\nhelp = result.output.replace(\"Usage: cli\", \"Usage: ospeak\")\ncog.out(\n    \"```\\n{}\\n```\".format(help)\n)\n]]] -->\n```\nUsage: ospeak [OPTIONS] [TEXT]\n\n  CLI tool for running text through OpenAI Text to speech\n\n  Set the OPENAI_API_KEY environment variable to your OpenAI API key to avoid\n  using the --token option every time.\n\n  Example usage:\n\n      ospeak \"Everyone deserves a pelican\" --voice alloy -x 1.5\n\nOptions:\n  --version                       Show the version and exit.\n  -v, --voice [alloy|echo|fable|onyx|nova|shimmer|all]\n                                  Voice to use\n  -m, --model TEXT                Model to use - defaults to tts-1\n  -o, --output FILE               Save audio to this file on disk\n  -x, --speed FLOAT RANGE         Speed of the voice  [0.25<=x<=4.0]\n  -s, --speak                     Speak the text even when saving to a file\n  --token TEXT                    OpenAI API key\n  --help                          Show this message and exit.\n\n```\n<!-- [[[end]]] -->\n\n## Development\n\nTo contribute to this tool, first checkout the code. Then create a new virtual environment:\n```bash\ncd ospeak\npython -m venv venv\nsource venv/bin/activate\n```\nNow install the dependencies and test dependencies:\n```bash\npip install -e '.[test]'\n```\nTo run the tests:\n```bash\npytest\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "CLI tool for running text through OpenAI Text to speech",
    "version": "0.3",
    "project_urls": {
        "CI": "https://github.com/simonw/ospeak/actions",
        "Changelog": "https://github.com/simonw/ospeak/releases",
        "Homepage": "https://github.com/simonw/ospeak",
        "Issues": "https://github.com/simonw/ospeak/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "53908ca55938e59ebde58c0038c248898e0f1f068727ca2c40aa9d6d938267e6",
                "md5": "d147c3b9e8bbc63ea2d3c25260ff6f53",
                "sha256": "084c16a797950381972860a7506dffe97735f7267398c30f350f50717a905aa6"
            },
            "downloads": -1,
            "filename": "ospeak-0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d147c3b9e8bbc63ea2d3c25260ff6f53",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9182,
            "upload_time": "2023-12-13T06:13:15",
            "upload_time_iso_8601": "2023-12-13T06:13:15.682760Z",
            "url": "https://files.pythonhosted.org/packages/53/90/8ca55938e59ebde58c0038c248898e0f1f068727ca2c40aa9d6d938267e6/ospeak-0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ada84b0b0c962bfe35076171790012826fda8ce4e78ee480bc5cc9babc1111a9",
                "md5": "60fff43d79bd01d8e7344d078ebee6b0",
                "sha256": "ba3a44038d3701d632105bb0755b681297405fe0b84d1f402d2ab85488028b3f"
            },
            "downloads": -1,
            "filename": "ospeak-0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "60fff43d79bd01d8e7344d078ebee6b0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8815,
            "upload_time": "2023-12-13T06:13:17",
            "upload_time_iso_8601": "2023-12-13T06:13:17.211664Z",
            "url": "https://files.pythonhosted.org/packages/ad/a8/4b0b0c962bfe35076171790012826fda8ce4e78ee480bc5cc9babc1111a9/ospeak-0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-13 06:13:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "simonw",
    "github_project": "ospeak",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ospeak"
}
        
Elapsed time: 0.15637s