This project demonstrates a WebSocket connection to the Play.ai API for real-time audio communication.
Before you begin, ensure you have met the following requirements:
- You have a Play.ai account and have obtained your API key and Agent ID.
- Node.js and npm are installed on your machine.
-
Clone this repository to your local machine.
-
Navigate to the project directory and run
npm install
to install dependencies. -
Create a
.env
file in the root directory with the following content:REACT_APP_PLAY_AI_AGENT_ID=your_agent_id_here REACT_APP_PLAY_AI_API_KEY=your_api_key_here
Replace
your_agent_id_here
andyour_api_key_here
with your actual Play.ai Agent ID and API key.
In the project directory, you can run:
This runs the app in development mode. Open http://localhost:3000 to view it in your browser.
- Real-time WebSocket connection to Play.ai API
- Audio streaming and playback
- Handling of various message types from the API
If you encounter any issues with audio playback or WebSocket connection, check the browser console for error messages and ensure your API credentials are correct in the .env
file.
Contributions to improve the demo are welcome. Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature-name
) - Make your changes
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/your-feature-name
) - Create a new Pull Request
This project is licensed under the MIT License.