Simple voice assistant written in Python.
The assistant can listen through the microphone, convert speech to text, process simple commands, and reply using synthesized speech.
- Basic English command support.
- Configurable language setting.
- Record audio from microphone.
- Convert speech to text.
- Reply with synthesized voice.
- Run continuously in a loop.
- Exit when the user says "tạm biệt".
- Simple command processing through a separate brain module.
- Modular project structure for future expansion.
- Windows
- Python 3.11 or newer
- Microphone
- Internet connection (for speech recognition and gTTS)
assistant/
├── config.py
├── main.py
├── listen.py
├── brain.py
├── speak.py
└── audio/
Main entry point.
Controls the assistant workflow:
Listen -> Think -> Speak
Handles:
- Audio recording
- Speech recognition
Handles:
- Command processing
- Response generation
Examples:
xin chào
Hello
bạn tên gì
Mấy giờ rồi?
what time is it
tạm biệt
good bye
Handles:
- Text-to-speech generation
- Audio playback
pip install -r requirements.txtor
pip install sounddevice
pip install scipy
pip install SpeechRecognition
pip install gtts
pip install pygame-ceThe assistant language can be changed in:
# config.py
LANG = "vi-VN"Examples:
LANG = "vi-VN"Vietnamese
LANG = "en-US"English
After changing the language, restart the assistant.
Open a terminal inside the project folder:
python main.pyExample:
Tôi đang nghe đây
đang nhận diện
User:
xin chào
hello
Assistant:
Chào bạn
User:
bạn tên gì vậy
bạn tên gì
what is your name
what's your name
Assistant:
Tôi là trợ lí ảo của bạn
I am your virtual assistant
User:
mấy giờ rồi
what time is it
Assistant:
Bây giờ là 17 giờ 5 phút
It is 17:05
User:
hôm nay là ngày mấy
ngày mấy
ngày bao nhiêu
what is today's date
what's today's date
what is the date today
what's the date
what day is it today
what day is it
Assistant:
Hôm nay là ngày 15 tháng 6 năm 2026
Today is June 15, 2026
User:
tạm biệt bạn
bye
kết thúc
tạm biệt
thoát
good bye
goodbye
Assistant:
Tạm biệt bạn, cần giúp gì thì nói mình nhé
good bye
The program will then exit.
Install:
pip install SpeechRecognitionInstall:
pip install sounddeviceThe audio file may still be in use.
Make sure pygame has finished playing the file before deleting or recreating it.
Speech recognition could not understand the audio.
Try:
- Speaking more clearly
- Reducing background noise
- Increasing recording duration
- Open applications by voice.
- Search Google.
- Read weather information.
- Wake word support.
- AI integration.
Do not store passwords or sensitive information inside source code.
Keep API keys and tokens in environment variables whenever possible.
MIT License