0% found this document useful (0 votes)
5 views2 pages

Alexa

The document outlines a Python script for a voice assistant named 'Alexa' that utilizes libraries for speech recognition, text-to-speech, and various functionalities like playing music, telling time, and providing information from Wikipedia. It includes functions to listen for commands, respond with speech, and execute specific tasks based on recognized phrases. The script also handles errors and has a basic structure for command recognition and processing.

Uploaded by

shriyasikka1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Alexa

The document outlines a Python script for a voice assistant named 'Alexa' that utilizes libraries for speech recognition, text-to-speech, and various functionalities like playing music, telling time, and providing information from Wikipedia. It includes functions to listen for commands, respond with speech, and execute specific tasks based on recognized phrases. The script also handles errors and has a basic structure for command recognition and processing.

Uploaded by

shriyasikka1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

import speech_recognition as sr

import pyttsx3

import pywhatkit

import datetime

import wikipedia

import pyjokes

listener= sr.Recognizer()

engine = pyttsx3.init()

voices =engine.getProperty('voices")

engine.setProperty('voice', voices[1].id)

def talk(text):

engine.say(text)

engine.runAndiWait()

wikipedia.summary(person, 1)

print(info)

talk(info)def take_command():

try:

with sr.Microphone() as source:

print('listening...')

voice = listener.listen(source)

command = listener.recognize_google(voice)

command = command.lower()

if alexa in command:

command = command.replace('alexa', '')

print(command)

except :

pass
return command

def run_alexa():

command take command()

print(command)

if play in command:

song command.replace("play

talk playing song)

pywhatkit.playonyt (song)

elif tine in command:

time datetime.datetime.now().strftime()

talk("Current tine is time)

elif who the heck is in command

person command, replace(who the

info

elif date in command:

talk(sorry, I have a headache')

#lif are you single in commands

talkan a relationship with wif

elif Joke in command:

talk(pyjokes.get_joke())

viser

talk( Please say the command aga

WiLLe Trues

run alexa()

You might also like