Giter Site home page Giter Site logo

openai-text-to-speech's Introduction

OpenAI Text-to-Speech Script

A python script to generate open AI's text-to-speech audio files.

This Python script uses the OpenAI API to generate speech from text. It allows you to specify the input text, voice, and model for speech generation. Additionally, you can provide the input text from a text file.

Prerequisites

Before using this script, make sure you have the following:

  1. Python 3.7 or later installed on your system.
  2. An OpenAI account with API access credentials. You can sign up for an account and get your API key from the OpenAI website.

Installation

  1. Clone this repository or download the script.

  2. Install the required dependencies using Pipenv:

    pipenv install
    
  3. set your OpenAI API key as an environment variable:

        export OPENAI_API_KEY=your_api_key_here

Usage

You can use the script to generate speech with the following options:

--text-file: Specify the path to a text file containing the input text.

--voice: (Optional) Choose a voice for speech generation (default: onyx). Available voices are (alloy, echo, fable, onyx, nova, and shimmer)

--model: (Optional) Specify the model for speech generation (default: tts-1-hd). 'tts-1' is cheaper and lower quality.

--output-file: (Optional) Specify the path to save the generated audio file.

--format: (Optional) Specify the format of the generated audio file (default: mp3). Available formats are (mp3, opus, flac, and aac).

Note: The input text shouldn't exceed 4096 characters. Split the input text into smaller chunks if necessary.

Example Usages:

Generate speech from text:

pipenv run python your_script.py "Your text input"

Generate speech from text file with a custom voice and output format:

pipenv run python main.py --text-file "input.txt" --voice "fable" --format "aac"

openai-text-to-speech's People

Contributors

julioevm avatar

Watchers

 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.