DeveloperBreeze

Tutorials Programming Tutorials, Guides & Best Practices

Explore 149+ expertly crafted tutorials 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

Let’s add functionality to respond to basic tasks like saying the time, performing web searches, or opening apps.

import datetime
import pywhatkit

def process_command(command):
    if "time" in command:
        now = datetime.datetime.now().strftime("%H:%M")
        speak(f"The time is {now}")
    elif "search for" in command:
        query = command.replace("search for", "").strip()
        speak(f"Searching for {query}")
        pywhatkit.search(query)
    elif "play" in command:
        song = command.replace("play", "").strip()
        speak(f"Playing {song}")
        pywhatkit.playonyt(song)
    else:
        speak("I'm sorry, I can't perform that task yet.")

How to Convert Audio to Text with Python

Tutorial August 04, 2024
python

To improve the accuracy of the transcription, consider the following:

  • Quality of Audio: Ensure the audio is clear and has minimal background noise.
  • Sampling Rate: Higher sampling rates can improve recognition accuracy.
  • Language: Specify the language if it's different from the default (English) by passing language='language_code' to the recognize_google function.