A Python voice chatbot that acts as "Bob the pizza guy" and handles pizza-order conversations end-to-end using speech input and spoken responses.
It combines:
- Speech-to-text with Whisper
- Chat completion with Groq (
llama3-8b-8192) - Text-to-speech with OpenAI (
tts-1) - Audio playback with
pygame
- Video demo: Chatbot Demo
- Voice-based user input from microphone
- Persona-driven pizza ordering assistant prompt
- Conversation memory across turns in the same session
- Spoken assistant responses via generated
assistant.mp3
myChatbot/
├── README.md
└── chatbot/
├── main.py
├── requirements.txt
└── .gitignore
- Python 3.9+
groqSDK for LLM chat responsesopenaiSDK for text-to-speechSpeechRecognition+whisper+soundfile+numpyfor transcriptionpygamefor local audio playbackpython-dotenvfor environment variables
- Python 3.9 or newer
- Working microphone
- API keys:
GROQ_API_KEYOPENAI_API_KEY
-
Clone the repository and go to the project:
git clone <your-repo-url> cd myChatbot/chatbot
-
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile inchatbot/:GROQ_API_KEY=your_groq_api_key_here OPENAI_API_KEY=your_openai_api_key_here
From the chatbot/ directory:
python main.pyThen speak into your microphone when prompted with say something....
- Captures audio from the microphone.
- Converts speech to text with Whisper.
- Sends the transcribed text to Groq chat completion.
- Converts assistant response text to speech using OpenAI TTS.
- Plays the generated response audio locally with
pygame.
- The app currently loops forever until manually stopped (
Ctrl+C). assistant.mp3is written on each response and not deleted automatically.- The assistant is intentionally restricted to pizza-ordering conversations.
- First-time Whisper model loading can take longer and may require additional ML runtime dependencies.
- Microphone not detected
- Check OS microphone permissions and default input device.
- No audio playback
- Confirm system audio output is working and
pygameinitialized correctly.
- Confirm system audio output is working and
- API/auth errors
- Verify
.envkeys are valid and loaded.
- Verify
- Whisper/ML dependency issues
- Ensure all requirements are installed in the active virtual environment.
- Add text-input fallback mode
- Add graceful exit command (for example: "quit")
- Delete temporary audio files after playback
- Add unit and integration tests
- Package as a CLI application