An interactive voice chat application that enables real-time conversations with an AI assistant using OpenAI's APIs. The application supports voice input, text processing, and voice output, creating a natural conversation flow with the AI.
- 🎤 Real-time voice recording
- 🔄 Speech-to-text conversion using OpenAI's Whisper API
- 💭 AI-powered responses using GPT-3.5 Turbo
- 🔊 Text-to-speech output using OpenAI's TTS API
- 💾 Conversation history tracking
- ⌨️ Simple keyboard controls
- Node.js (v14 or higher)
- FFmpeg
- OpenAI API key
- Working microphone and speakers
- Clone the repository:
git clone <repository-url>
cd ai-voice-chat- Install dependencies:
npm install- Create a
.envfile based on.env.example:
cp .env.example .env- Add your OpenAI API key to the
.envfile:
OPENAI_API_KEY=your_openai_api_key_here- Start the application:
node ttsChat.jsor
OPENAI_API_KEY=your_openai_api_key_here node ttsChat.js- Controls:
- Press
Enterto start recording - Press
Enteragain to stop recording and process your message - Press any other key to exit
- Use
Ctrl+Cto force quit
node-microphone: For audio inputfluent-ffmpeg: For audio processingffmpeg-static: FFmpeg binariesaxios: For API requestsspeaker: For audio outputopenai: OpenAI API clientdotenv: Environment variable managementform-data: For handling multipart form data
The application uses several configurable parameters:
- Voice Settings:
- Default voice: "echo"
- TTS model: "tts-1"
- Chat Model: GPT-3.5 Turbo
- Audio Settings:
- Channels: 2 (Stereo)
- Bit Depth: 16
- Sample Rate: 44100 Hz
- Audio file size limit: 25MB for Whisper API
- Requires a stable internet connection
- OpenAI API usage is subject to API pricing
The application includes error handling for:
- Microphone recording issues
- API communication errors
- Audio processing problems
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request