This project implements a simple voice-controlled personal assistant in Python. The assistant listens to spoken user commands, converts them to text, processes them, and responds using text-to-speech output.
The assistant can greet the user, speak the current time, search Wikipedia for people, and exit on command.
The assistant currently supports the following capabilities:
- Speech recognition using microphone input
- Text-to-speech responses
- Time announcements
- “Who is …” queries using Wikipedia summaries
- Greeting based on time of day
- Exit on voice commands: stop / exit / bye
| Component | Library |
|---|---|
| Speech recognition | speech_recognition |
| Text to speech | pyttsx3 |
| Knowledge lookup | wikipedia |
| Date and time | datetime |
Install dependencies before running the assistant:
pip install SpeechRecognition
pip install pyttsx3
pip install wikipedia
pip install pyaudioNote: On some systems,
pyaudiomust be installed separately (for example via system package manager or wheel file).
-
Initializes text-to-speech engine
-
Greets user based on current time
-
Continuously listens to microphone input
-
Recognizes speech using Google Speech API
-
Processes commands such as:
- “what is the time”
- “who is Albert Einstein”
- “what is your name”
-
Speaks responses back to the user
-
Stops when user says:
- stop
- exit
- bye
Run the script:
python main.pyMake sure:
- a working microphone is connected
- internet connection is available (for speech recognition and Wikipedia lookup)
The program uses microphone index:
mic_id = 1If your microphone index is different, list available microphones:
import speech_recognition as sr
sr.Microphone.list_microphone_names()Then update mic_id accordingly.