Code Monkey home page Code Monkey logo

ospeak's Introduction

ospeak

PyPI Changelog Tests License

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

See ospeak: a CLI tool for speaking text in the terminal via OpenAI for background on this project.

Installation

Install this tool using pipx:

pipx install ospeak

This tool also depends on ffmpeg. You can install that on macOS using Homebrew like this:

brew install ffmpeg

Note that ospeak has dependencies that are currently incompatible with LLM (see this issue) so the two tools need to be installed in different virtual environments, hence the recommendation to use pipx.

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

ospeak's People

Contributors

simonw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.