Skip to main content

CLI tool for running text through OpenAI Text to speech

Project description

ospeak

PyPI Changelog Tests License

CLI tool for running text through the OpenAI Text to speech API and speaking or saving the result

Installation

Install this tool using pipx:

pipx install ospeak

Usage

To get your computer to say something, run:

ospeak "Hello there"

You will need an OpenAI API key. You can set that as an environment variable:

export OPENAI_API_KEY="..."

Or you can pass it using --token:

ospeak --token "..." "Hello there"

You can pipe content into the tool:

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.

ospeak "This is my voice" -v all

To adjust the speed, pass -x/--speed with a value between 0.25 and 4 (the default is 1.0):

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:

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:

ospeak "This is my voice" -o voice.mp3 -s

ospeak --help

Usage: ospeak [OPTIONS] [TEXT]

  CLI tool for running text through OpenAI Text to speech

Options:
  --version                       Show the version and exit.
  -v, --voice [alloy|echo|fable|onyx|nova|shimmer|all]
                                  Voice to use
  -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.

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd ospeak
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ospeak-0.2.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

ospeak-0.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file ospeak-0.2.tar.gz.

File metadata

  • Download URL: ospeak-0.2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for ospeak-0.2.tar.gz
Algorithm Hash digest
SHA256 056096ee7544d5cc6898481e67cc4781da9b34e443caf770245977816e75a5c1
MD5 7083c3a3674ce82f048243840d9b76e6
BLAKE2b-256 4acc2a88376924f571dc208fb0b13959a3aa6747e0dd8def5bb75ff6b97ec741

See more details on using hashes here.

File details

Details for the file ospeak-0.2-py3-none-any.whl.

File metadata

  • Download URL: ospeak-0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for ospeak-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b1b6aeb5439c8b9cd5b2083b5706a2eeada50bbf10e98c179f22be6857ed7411
MD5 cb5e4729ae349456588b5fe9c3b9ca22
BLAKE2b-256 01a055a51ad72ec220651b8224b256c2fcf57c6accc407ec16ef665a207553c8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page