Answers for "create virtual assistant python"

13

create a virtualenv python

pip install virtualenv
cd projectfolder #go to project folder
virtualenv projectname #create the folder projectname 
source projectname/bin/activate
Posted by: Guest on April-30-2020
2

create virtual environment python

sudo pip3 install virtualenv 

virtualenv venv
Posted by: Guest on December-09-2020
0

how to make a virtual assistant with python

import speech_recognition as mic
import pyttsx3
import pywhatkit
import datetime
import wikipedia
import pyjokes

listener = mic.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)


def talk(text):
    engine.say(text)
    engine.runAndWait()


def take_command():
    try:
        with sr.Microphone() as source:
            print('Yeah I am listening!')
            voice = listener.listen(source)
            command = listener.recognize_google(voice)
            command = command.lower()
            if 'google' in command:
                command = command.replace('google', '')
                print(command)
    except:
        pass
    return command


def run_alexa():
    command = take_command()
    print(command)
    if 'play song' in command:
        song = command.replace('play', '')
        talk('playing ' + song)
        pywhatkit.playonyt(song)
    elif 'time' in command:
        time = datetime.datetime.now().strftime('%I:%M %p')
        talk('The current time is ' + time)
    elif 'who is' in command:
        person = command.replace('who the heck is', '')
        info = wikipedia.summary(person, 1)
        print(info)
        talk(info)
    elif 'date' in command:
        talk('sorry, I have a headache')
    elif 'are you single' in command:
        talk('No, my best freind is you!')
    elif 'joke' in command:
        talk(pyjokes.get_joke())
    else:
        talk('Sorry I did not get that')


while True:
    run_alexa()
    
    #you have to install the following by the commands.Just copy and paste each text given
    #below, you can paste it on the code editors terminal or in cmd.
    #pip install SpeechRecognition
    #pip install pyttsx3
    #pip install pywhatkit
    #pip install DateTime
    #pip install wikipedia
    #pip install PyAudio
    #pip install pyjokes
Posted by: Guest on July-17-2021

Code answers related to "create virtual assistant python"

Python Answers by Framework

Browse Popular Code Answers by Language