Prerequisites
Before you begin, ensure you have the following installed:- Python 3.9+ for the backend
- Node.js 14+ and npm for the frontend
- OpenAI API Key - Get one from OpenAI Platform
Installation
Set up the backend
Install the Python dependencies:The backend requires these packages:
fastapi==0.109.0- Web frameworkuvicorn==0.27.0- ASGI serveropenai==1.66.3- OpenAI API clientpsutil==5.9.8- System metricspython-multipart==0.0.9- File upload supportwebsockets==12.0- WebSocket support
Start the backend server
Run the FastAPI server using uvicorn:The server will start on
http://localhost:10000. You should see:Test Your Setup
Once both servers are running:- Open your browser to
http://localhost:3000 - Click the “Start Detection” button
- Allow microphone access when prompted
- Speak in any language for 4-15 seconds
- The detected language will appear on screen
API Endpoints
Your local backend exposes these endpoints:| Endpoint | Method | Description |
|---|---|---|
/ | GET | Health check - returns {"message": "Server is running!"} |
/metrics | GET | Server metrics including CPU, memory, and request stats |
/ws | WebSocket | Real-time language detection endpoint |
Configuration
You can customize the backend behavior with environment variables:| Variable | Default | Description |
|---|---|---|
OPENAI_API_KEY | Required | Your OpenAI API key |
PORT | 10000 | Backend server port |
DEBUG | false | Enable debug logging |
Troubleshooting
Microphone permission denied
Microphone permission denied
If your browser blocks microphone access:
- Check browser permissions (usually in the address bar)
- Ensure you’re using HTTPS or localhost
- Try a different browser (Chrome and Firefox work best)
WebSocket connection failed
WebSocket connection failed
If the frontend can’t connect to the backend:
- Verify the backend is running on port 10000
- Check that CORS is configured correctly in
settings.py - Ensure
http://localhost:3000is in theCORS_ORIGINSlist
OpenAI API errors
OpenAI API errors
If you see API-related errors:
- Verify your API key is set correctly
- Check you have credits in your OpenAI account
- Ensure you have access to the Whisper API
- Check rate limits (max 3 concurrent calls by default)
Audio too short error
Audio too short error
If your audio is rejected:
- Speak for at least 4 seconds (minimum required)
- Ensure audio is being captured (check the microphone level indicator)
- Verify your microphone is working in other applications
Next Steps
Explore Features
Learn about real-time detection and audio processing
Deploy to Production
Deploy LangShazam to your infrastructure
API Reference
Dive into the WebSocket API documentation
Architecture
Understand the system architecture

