Talk to your computer and it talks back: greetings, the time, and more.
Built and tested by Aboobacker sidheeq K P · Industrial Robotics Institute
Python 3.11, SpeechRecognition, pyttsx3, PyAudio, PyCharm (recommended)
A voice assistant that lets you talk to your computer instead of typing. It listens through the microphone, turns your speech into text with speech recognition, picks a reply based on what you said, and speaks the answer back with text-to-speech. It shows the basics of AI speech recognition and voice output in a short Python program.
| Component | Qty |
|---|---|
| Laptop / Computer | 1 |
| Microphone (built-in or external) | 1 |
| Speaker / Headphones | 1 |
Complete, tested Python code for this project. Copy it into Python 3.11 and upload it and run it.
import speech_recognition as sr
import pyttsx3
import datetime
import time
def speak(text):
print("Assistant:", text)
engine = pyttsx3.init()
engine.setProperty('rate', 170)
engine.setProperty('volume', 1.0)
engine.say(text)
engine.runAndWait()
engine.stop()
recognizer = sr.Recognizer()
recognizer.energy_threshold = 300
recognizer.pause_threshold = 0.8
def listen():
try:
with sr.Microphone() as source:
print("\nListening...")
recognizer.adjust_for_ambient_noise(source, duration=0.3)
audio = recognizer.listen(source, timeout=5, phrase_time_limit=5)
print("Recognizing...")
command = recognizer.recognize_google(audio, language="en-IN")
print("You:", command)
return command.lower()
except Exception:
return ""
def reply(cmd):
if cmd == "":
return True
elif "hello" in cmd:
speak("Hello sir")
elif "time" in cmd:
now = datetime.datetime.now().strftime("%I:%M %p")
speak(f"The time is {now}")
elif "goodbye" in cmd or "stop" in cmd:
speak("Goodbye sir")
return False
elif "name" in cmd:
speak("I'm your voice assistant")
else:
speak("Please repeat")
return True
print("Starting Assistant...")
speak("Voice assistant started")
running = True
while running:
command = listen()
running = reply(command)
print("Program Closed")A voice assistant that lets you talk to your computer instead of typing. It listens through the microphone, turns your speech into text with speech recognition, picks a reply based on what you said, and speaks the answer back with text-to-speech.
You need: Laptop / Computer (1), Microphone (built-in or external) (1), Speaker / Headphones (1). Software: Python 3.11, SpeechRecognition, pyttsx3, PyAudio, PyCharm (recommended).
Yes. It is rated beginner and takes about 1–2 hours to build, using the Laptop / PC with microphone. The guide on this page explains every connection and step.
The complete, tested Python code is free on this page. Copy it into Python 3.11 and upload it and run it.
No kit is needed. This project runs on a laptop or PC with microphone. For help with the setup, message IRI on WhatsApp at +91 86060 82634.