Translation Demo
This project demonstrates how to use the OpenAI Realtime API to build a one-way translation application with WebSockets. It is implemented using the Realtime + Websockets integration. A real-world use case for this demo is multilingual, conversational translation—where a speaker talks into the speaker app and listeners hear translations in their selected native languages via the listener app. Imagine a conference room with multiple participants with headphones, listening live to a speaker in their own languages. Due to the current turn-based nature of audio models, the speaker must pause briefly to allow the model to process and translate speech. However, as models become faster and more efficient, this latency will decrease significantly and the translation will become more seamless.
How to Use
Running the Application
-
Set up the OpenAI API:
- If you're new to the OpenAI API, sign up for an account.
- Follow the Quickstart to retrieve your API key.
-
Clone the Repository:
git clone <repository-url> -
Set your API key:
- Create a
.envfile at the root of the project and add the following line:REACT_APP_OPENAI_API_KEY=<your_api_key>
- Create a
-
Install dependencies:
Navigate to the project directory and run:
npm install -
Run the Speaker & Listener Apps:
npm startThe speaker and listener apps will be available at:
-
Start the Mirror Server:
In another terminal window, navigate to the project directory and run:
node mirror-server/mirror-server.mjs