This repository features a Gradio interface designed to leverage the OpenAI Text-To-Speech (TTS) API. The interface lets users create speech from provided text using different models and voice options.
To begin using this interface, follow these steps:
-
Clone this repository to your local machine.
git clone https://github.com/arham-kk/openai-tts.git cd openai-tts
-
Install the required dependencies.
pip install -r requirements.txt
Ensure that the following dependencies are installed:
gradio
openai
You can install them using:
pip install -r requirements.txt
- Obtain an OpenAI API key and enter it into the provided textbox.
- Choose a TTS model (
tts-1
ortts-1-hd
) and a voice option from (alloy
,echo
,fable
,onyx
,nova
,shimmer
). - Input the desired text into the input textbox.
- Click the "Generate" button or press Enter to create the corresponding speech.
- The generated speech will be displayed as an audio output.
The code is organized into two main components:
tts
: This module contains the function responsible for interacting with the OpenAI API to generate speech.gradio_interface
: This module sets up the Gradio interface, including input fields, buttons, and the speech output.
Follow these steps to set up and run the Gradio interface:
-
Obtain your OpenAI API key.
- If you don't have an API key, sign up for one on the OpenAI website.
- Replace the placeholder in the interface with your API key.
-
Run the Gradio interface.
python app.py
-
Input your text and choose the desired model and voice options.
-
Click the "Generate" button or press Enter to generate speech.
This code is provided under the MIT License. Feel free to modify and distribute it as needed.