This project provides a simple web-based interface for the RealtimeTTS library, specifically utilizing the OpenAI engine for text-to-speech conversion. It allows you to enter text, adjust the speaking speed, and listen to the generated audio in real-time.
This is a fork of the original RealtimeTTS project.
- Web-Based UI: A clean and simple interface to interact with the TTS engine.
- Real-time Audio Streaming: Audio is streamed from the server to the client as it's generated.
- Adjustable Speaking Speed: Control the speed of the speech from 0.5x to 2.0x.
- Stop Functionality: Interrupt the audio playback at any time.
- HTML to Markdown on Paste: Automatically converts rich text pasted into the text area into clean Markdown.
The application is built with a Python backend and a vanilla JavaScript frontend:
- Backend: A FastAPI server (
app.py) that handles the text-to-speech generation using theRealtimeTTSlibrary with theOpenAIEngine. It exposes endpoints to start the TTS stream (/tts), stop it (/stop), and convert HTML to Markdown (/html_to_markdown). - Frontend: A single HTML page with JavaScript (
static/tts.js) that communicates with the backend. It captures user input, sends requests to the server, and plays the received audio stream in the browser.
Follow these steps to get the application running on your local machine.
git clone <repository-url>
cd <repository-directory>It's recommended to use a virtual environment to manage dependencies.
# For Windows
python -m venv venv
venv\Scripts\activate
# For macOS/Linux
python3 -m venv venv
source venv/bin/activateInstall all the required Python packages from requirements.txt.
pip install -r requirements.txtThe application requires an OpenAI API key to function.
-
Create a file named
.envin the root of the project directory. -
Add your OpenAI API key to the
.envfile:OPENAI_API_KEY="your-openai-api-key" -
(Optional) You can also specify the port on which the server will run:
TTS_FASTAPI_PORT=8000
-
Start the Server: Run the
app.pyscript from your terminal:python app.py
-
Access the Web Interface: Open your web browser and navigate to: http://localhost:8000 (or the port you specified).
-
Use the Application:
- Enter the text you want to convert to speech in the text area.
- Adjust the reading speed using the slider.
- Click the "Speak" button to start the audio.
- Click the "Stop" button to end the playback.
This fork focuses solely on providing this web interface. For more details on the underlying TTS library, please refer to the original RealtimeTTS repository.