Coders Packet

Create a virtual voice assistant in Python

By Siddhant prabhakar

Create virtual voice assistant in Python using Pycharm or VS code. import pyttsx3, Wikipedia, speechRecognition, pyaudio modules from the terminal in Pycharm or VS code.

import pyttsx3 modules, Pyaudio from terminal. If microphone faces problem in code use k.adjust_for_ambient_noise(source,duration=1) for noise cancellation in def inter

import speech_recognition as bt
import pyttsx3
import os
import webbrowser
import wikipedia
import datetime
import smtplib

e = pyttsx3.init('sapi5')
v = e.getProperty('voices')
e.setProperty('voice', v[0].id)

def bolo(audio):

def siddhant():
    g = int(
    if g>=12 and g<18:

    elif g>=0 and g<12:
        bolo("raam raam")

        bolo("hello sir...")

    bolo("my name is allexa.  can you please tell me how could I serve you")

def inter():

    k = bt.Recognizer()
    with bt.Microphone() as h:
        print("  sidhant bro i am trying to Listen...")
        k.pause_threshold = 1
        audio = k.listen(h)

        print("kaam kr rha hoo....")
        q = k.recognize_google(audio, language='en-in')
        print(f"User said: {q}\n")

    except Exception as m:

        print("phir se bolo...")
        return "None"
    return q

if __name__ == "__main__":
    while True:

        q = inter().lower()

        if 'wikipedia' in q:
            bolo('Searching results...')
            q = q.replace("wikipedia", "")
            x = wikipedia.summary(q, sentences=2)
            bolo("According to results")

        elif 'open youtube' in q:

        elif 'open google' in q:


Download project

Reviews Report

Submitted by Siddhant prabhakar (siddhant142)

Download packets of source code on Coders Packet