0% found this document useful (0 votes)
14 views3 pages

V Assist

Uploaded by

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

V Assist

Uploaded by

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

import pyttsx3

import speech_recognition as sr
import webbrowser
from vcalculator import voice_calculator
from hand import start_hand_tracking
from pose import start_pose_tracker
from threading import Event

# Initialize text-to-speech engine


engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[2].id)

def speak(audio):
engine.say(audio)
engine.runAndWait()

speak("Hi, I'm Multi.")


speak("I'm a Nature Friendly Personal Voice Assistant")

speak('')

def listen():
"""Function to listen to the user's voice input"""
recognizer = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
recognizer.adjust_for_ambient_noise(source)
audio = recognizer.listen(source)
try:
query = recognizer.recognize_google(audio)
print(f"You said: {query}")
return query.lower()
except sr.UnknownValueError:
print("Sorry, I couldn't understand that.")
speak("Sorry, I couldn't understand that.")
return None
except sr.RequestError:
print("Sorry, the service is down.")
speak("Sorry, the service is down.")
return None

print("Initially, if you want to exit this page, then say 'exit'")


speak("Initially, if you want to exit this page, then say 'exit'")

while True:
speak('How can I assist you?')
query = listen()

if query == 'hey multi':


speak("Hi, How can I assist you?")
print("Hi, How can I assist you?\n")

elif query == 'search google':


speak('OK, Here we go.. What would you like me to search for?')
topic = listen()
if topic:
search_url = f"https://www.google.com/search?q={topic.replace(' ',
'+')}"
webbrowser.open(search_url)
speak(f'Searching Google for {topic}')
print(f'Searching Google for {topic}')

elif query == 'what is the best school in tirupati':


webbrowser.open('https://slateschool.in/')
speak('Here is the Result')
speak('And this is the best school in Tirupati')

elif query == 'open ai':


speak("Choose an option: Say 'open ai' or 'search open ai'.")
choice = listen()

if choice == 'open ai': # Exact match


webbrowser.open('https://chatgpt.com/')
speak('Opening ChatGPT...')
elif choice == 'search open ai': # Exact match
speak("OK, Here we go.. What would you like me to search for?")
topic = listen()
if topic:
search_url = f"https://chatgpt.com/?q={topic.replace(' ', '%20')}"
webbrowser.open(search_url)
speak(f'Searching ChatGPT based on {topic}')
print(f'Searching ChatGPT based on {topic}')
else:
speak("Invalid choice, Please try again.")

elif query == 'exit':


speak("See you again bye.")
print("See you again bye my friend.\n")
break

elif query == 'hand tracking module':


speak("Starting hand tracking module now...")

# Blocking call to hand tracking function with a 5-second limit


start_hand_tracking(duration=5) # Run hand tracking for 5 seconds

speak("Hand tracking has stopped.")

elif query == 'voice calculator':


speak("Initiating Voice Calculator")

'''
Blocking call to voice calculator function with its own timing
until exit/quit is mentions in the command it will run without stoping
'''
voice_calculator()
speak("Voice Calculator is stopped now.")

elif query == 'pose tracking module':


speak("Starting pose tracking module now...")

# Blocking call to pose tracking function with a 5-second limit


start_pose_tracker(duration=5) # Run pose tracking for 5 seconds

speak("pose tracking has stopped.")


else:
speak('Unable to understand your command.')

You might also like