DeveloperBreeze

Ai Programming Tutorials, Guides & Best Practices

Explore 7+ expertly crafted ai tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Build a Voice-Controlled AI Assistant with Python

Tutorial December 10, 2024
python

import speech_recognition as sr

def listen_command():
    recognizer = sr.Recognizer()
    with sr.Microphone() as source:
        print("Listening...")
        try:
            audio = recognizer.listen(source)
            command = recognizer.recognize_google(audio)
            print(f"You said: {command}")
            return command.lower()
        except sr.UnknownValueError:
            print("Sorry, I didn't catch that.")
            return None

Use pyttsx3 to make your assistant speak responses.