How to Create Virtual Assistant Using Python | Creating Virtual Assistant Using Python | Simplilearn

Поділитися
Вставка
  • Опубліковано 29 жов 2024

КОМЕНТАРІ • 55

  • @SimplilearnOfficial
    @SimplilearnOfficial  2 роки тому +14

    🔥Data Scientist Masters Program (Discount Code - YTBE15) - www.simplilearn.com/big-data-and-analytics/senior-data-scientist-masters-program-training?PyDn2gU9DJo&Comments&UA-cam
    🔥IITK - Professional Certificate Course in Data Science (India Only) - www.simplilearn.com/iitk-professional-certificate-course-data-science?PyDn2gU9DJo&Comments&UA-cam
    🔥Caltech Post Graduate Program in Data Science - www.simplilearn.com/post-graduate-program-data-science?PyDn2gU9DJo&Comments&UA-cam
    🔥Brown University - Applied AI & Data Science - www.simplilearn.com/applied-ai-data-science-course?PyDn2gU9DJo&Comments&UA-cam

    • @tanusreesaha9311
      @tanusreesaha9311 Рік тому +2

      hi,can u help me for one issue?
      actually the speech recognization is not happening.it is not taking input and also None output i am getting only.
      import speech_recognition as sr
      import pyttsx3
      import pywhatkit
      import datetime
      import pyaudio
      r = sr.Recognizer()
      machine = pyttsx3.init()
      def talk(text):
      machine.say(text)
      machine.runAndWait()
      def input():
      try:
      with sr.Microphone(device_index = 0) as origin:
      print("listening")
      print((sr.Microphone.list_microphone_names()))
      speech = r.listen(origin)
      instruction = r.recognize_goggle(speech)
      instruction.lower()
      if "jarvis" in instruction:
      instruction = instruction.replace('jarvis', "")
      print(instruction)
      except:
      pass

      def play_instruction():
      instruction = input()
      instruction = None

      print(instruction)
      if instruction is not None and "play" in instruction:
      song=instruction.replace('play', "")
      talk("playing" + song)
      pywhatkit.playonyt(song)

      elif instruction is not None and 'time' in instruction:
      time = datetime.datetime.now().strftime('%I: %M%p ')
      talk('current time' + time)

      play_instruction()

    • @tuanarada5922
      @tuanarada5922 Рік тому +1

      how to import this code in a framework and create a completed application

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому +3

      Hi
      There seem to be a few issues in your code that might be causing the problem. Here are a few suggestions:
      1. You should rename your input() function to something else, as input is already a built-in function in Python and you don't want to override it.
      2. In the input() function, you're catching all exceptions with a try/except block, which means that you won't see any error messages if something goes wrong. Instead, try to catch specific exceptions so you can see what's happening.
      3. There's a typo in the r.recognize_google() method, which should be r.recognize_google() instead of r.recognize_goggle()
      Here's a modified version of your code with these issues fixed:
      import speech_recognition as sr
      import pyttsx3
      import pywhatkit
      import datetime
      r = sr.Recognizer()
      machine = pyttsx3.init()
      def talk(text):
      machine.say(text)
      machine.runAndWait()
      def get_instruction():
      try:
      with sr.Microphone(device_index=0) as source:
      print("listening")
      print(sr.Microphone.list_microphone_names())
      r.adjust_for_ambient_noise(source)
      audio = r.listen(source, timeout=5)
      instruction = r.recognize_google(audio)
      instruction = instruction.lower()
      if "jarvis" in instruction:
      instruction = instruction.replace('jarvis', "")
      print(instruction)
      return instruction
      except sr.WaitTimeoutError:
      print("Timeout waiting for speech input")
      except sr.UnknownValueError:
      print("Unable to recognize speech")
      except sr.RequestError as e:
      print("Error in request to speech recognition service; {0}".format(e))
      def play_instruction():
      instruction = get_instruction()
      print(instruction)
      if instruction is not None and "play" in instruction:
      song = instruction.replace('play', "")
      talk("playing " + song)
      pywhatkit.playonyt(song)
      elif instruction is not None and 'time' in instruction:
      time = datetime.datetime.now().strftime('%I:%M %p')
      talk('current time ' + time)
      play_instruction()
      This code should now listen for speech input, recognize it using Google's speech recognition service, and then carry out an action based on the recognized instruction.

  • @shoaibdalal4036
    @shoaibdalal4036 9 місяців тому +6

    Hii sir !!!. i am facing one error can u please help me. name 'instruction' is not defined. this is my error. please sir tell what should i do.

  • @gudibandipoojitha5060
    @gudibandipoojitha5060 Рік тому +7

    It is recognizing voice but it's not responding.? Can someone tell me how to fix it..?

  • @lexytaylormb
    @lexytaylormb Рік тому +3

    I loved this exercise thank you so much! How could I change the voice? Thank you in advance for your time!

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому

      Thank you for choosing us as your learning partner. We are thrilled to hear that you enjoyed your experience with us! If you are looking to expand your knowledge further, we invite you to explore our other courses in the description box.

  • @AVinay-gq7ou
    @AVinay-gq7ou Рік тому +1

    helpful but can be improved anywys thanks for video mate well done

  • @mendozaglaizealm.7863
    @mendozaglaizealm.7863 2 роки тому +2

    Yo this helped so much and I always appreciate th

    • @SimplilearnOfficial
      @SimplilearnOfficial  2 роки тому

      Hello thank you for watching our video .We are glad that we could help you in your learning !

  • @hiraksolanki2021
    @hiraksolanki2021 Рік тому +5

    when i play.. terminal showed...
    "typeError: argument of type 'function' is not iterable"

    • @abdulbasitchishti3590
      @abdulbasitchishti3590 Рік тому +1

      I got the same error and has resolved it.
      In first line of "play_jarvis()" function, make sure you have put the brackets., like this:
      instruction = input_instruction()

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому +1

      Hey
      You can refer to the above suggestion or try with this:
      Hi
      You can try this one:
      import speech_recognition as sr
      import pyttsx3
      import pywhatkit
      import datetime
      r = sr.Recognizer()
      machine = pyttsx3.init()
      def talk(text):
      machine.say(text)
      machine.runAndWait()
      def get_instruction():
      try:
      with sr.Microphone(device_index=0) as source:
      print("Listening...")
      r.adjust_for_ambient_noise(source)
      speech = r.listen(source)
      instruction = r.recognize_google(speech)
      instruction = instruction.lower()
      if "jarvis" in instruction:
      instruction = instruction.replace('jarvis', "")
      print(instruction)
      return instruction
      except sr.UnknownValueError:
      pass
      except sr.RequestError as e:
      print("Could not request results from Google Speech Recognition service; {0}".format(e))
      return None
      def play_instruction():
      instruction = get_instruction()
      print(instruction)
      if instruction is not None and "play" in instruction:
      song = instruction.replace('play', "")
      talk("Playing " + song)
      pywhatkit.playonyt(song)
      elif instruction is not None and 'time' in instruction:
      time = datetime.datetime.now().strftime('%I:%M %p')
      talk('The current time is ' + time)
      play_instruction()

  • @thisenekanayake2832
    @thisenekanayake2832 Рік тому

    Thank you so much❤

  • @AVMane-mx7rp
    @AVMane-mx7rp 9 місяців тому

    Best code. Thanks

  • @aman_rajput_shorts
    @aman_rajput_shorts 29 днів тому

    Sir program run krne k baad output mw yee sb likha aa rha h "Exited code =9009 in 0.828 seconds meaning"

  • @sairamapriya8563
    @sairamapriya8563 2 роки тому +1

    Thank you for the interesting session..

  • @obalisaikiran433
    @obalisaikiran433 2 роки тому +2

    Thank you sir

  • @sajidnazirtantray
    @sajidnazirtantray 5 місяців тому +1

    At start its showing pip is not recognized as internal or external comadn,...... What to do

    • @SimplilearnOfficial
      @SimplilearnOfficial  5 місяців тому

      If you’re seeing the "pip is not recognized as an internal or external command" error, it means that pip is not installed or not added to your system’s PATH. Here’s how to fix it:
      Install pip:
      If you don’t have pip installed, you can download and install it from the official website: pip.pypa.io/en/stable/installation/.
      Add pip to PATH:
      Open the Control Panel and go to System and Security > System > Advanced system settings.
      Click on Environment Variables.
      In the System variables section, find the PATH variable and select it. Click Edit.
      Add the path to the Scripts folder where pip is installed. For example, C:\Python39\Scripts\ (adjust according to your Python installation path).
      Click OK to save and close all dialogs.
      Verify Installation:
      Open a new command prompt window and type pip --version to check if pip is now recognized.
      If these steps don’t resolve the issue, consider reinstalling Python and ensuring that you select the option to add Python to PATH during installation.

  • @Blazerrrzz
    @Blazerrrzz Рік тому

    hi, i did the exact coding but still the assistant is answering only the "who is" question or either saying please repeat what can i do to fix it??

  • @GummadilliCharan
    @GummadilliCharan 4 місяці тому

    may i know how to open comand prompt

  • @AbdurrahamanJamiu
    @AbdurrahamanJamiu 9 місяців тому

    sir please what v.scode extemtion do i need for this

  • @simransingh984
    @simransingh984 5 місяців тому +1

    I am not receiving audio what should I do

    • @SimplilearnOfficial
      @SimplilearnOfficial  5 місяців тому

      Hi there, Please try to open this video in incognito window or you can use any other browser.

  • @Vignesh-f8k
    @Vignesh-f8k Рік тому +2

    I wish Jarvis had replied in bacha party way for who is Mahatma Gandhi 🙂

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому

      We're so glad that you enjoyed your time learning with us! If you're interested in continuing your education and developing new skills, take a look at our course offerings in the description box. We're confident that you'll find something that piques your interest!

  • @montageofchips
    @montageofchips Рік тому +2

    "we will respond to the stuffs if you have problem"
    later: only responds to the comments thanking them for the tutorial

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому

      Hey, Thank you for choosing us as your learning partner. If you have any queries, please feel free to reach out in comment section.

  • @Mona-bq4pf
    @Mona-bq4pf 10 місяців тому

    Front end and backend for this project plzzz

  • @leonhore9009
    @leonhore9009 Рік тому +1

    Mine says I have to update my pip installer

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому

      If your pip installer needs to be updated, you can do so using the following command in your terminal or command prompt:
      pip install --upgrade pip
      This will update pip to the latest version. After updating pip, you can install the SpeechRecognition package by running:
      pip install SpeechRecognition

  • @officialSoni....chaurasiya
    @officialSoni....chaurasiya Рік тому +1

    My also error if module is installed

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому

      Hey, Thank you for choosing us as your learning partner. Please specify your error.

  • @prashanthm3877
    @prashanthm3877 Рік тому

    tensorflow i guess

  • @Mona-bq4pf
    @Mona-bq4pf 10 місяців тому

    Plzzz reply is this AI project or not

  • @mitalisaxena1927
    @mitalisaxena1927 Рік тому +9

    It is showing error of NoModuleFoundError : No Module named 'speech_recognition' . However i have already installed SpeechRecognition amd checked also ..i didnt find any solution of it

    • @yashashvitravelwanderlust6149
      @yashashvitravelwanderlust6149 Рік тому +1

      i am having the same problem, did you fix it?

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому +5

      Hi
      If you've already installed the SpeechRecognition module but are still getting a ModuleNotFoundError, it's possible that the module was installed in a different Python environment than the one you're currently using.
      Here are a few things you can try to troubleshoot the issue:
      1. Check which version of Python you're using: Make sure that you're running the correct version of Python (i.e., the one where you installed the SpeechRecognition module). You can check your Python version by running python --version in your terminal or command prompt.
      2. Check the location of the installed module: You can check the location where the SpeechRecognition module is installed by running pip show speechrecognition in your terminal or command prompt. Make sure that the location matches the Python environment you're currently using.
      3. Install the module again: Try uninstalling and reinstalling the SpeechRecognition module using pip uninstall speechrecognition and pip install speechrecognition in your terminal or command prompt. This will ensure that the module is installed in the correct Python environment.
      4. Use a virtual environment: Consider using a virtual environment (such as venv or conda) to create a separate Python environment for your project. This can help ensure that the correct version of Python and the required modules are being used.
      I hope one of these suggestions helps you resolve the issue. Let me know if you have any further questions!

  • @amazingfactsaf513
    @amazingfactsaf513 Рік тому +1

    Tell about this error bhai

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому

      Hey, Thank you for choosing us as your learning partner. Please specify your error.

  • @tanishqtanishq6937
    @tanishqtanishq6937 Рік тому +2

    bro can u plzz provide source code

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому +2

      Hi
      You can try this one:
      import speech_recognition as sr
      import pyttsx3
      import pywhatkit
      import datetime
      r = sr.Recognizer()
      machine = pyttsx3.init()
      def talk(text):
      machine.say(text)
      machine.runAndWait()
      def get_instruction():
      try:
      with sr.Microphone(device_index=0) as source:
      print("Listening...")
      r.adjust_for_ambient_noise(source)
      speech = r.listen(source)
      instruction = r.recognize_google(speech)
      instruction = instruction.lower()
      if "jarvis" in instruction:
      instruction = instruction.replace('jarvis', "")
      print(instruction)
      return instruction
      except sr.UnknownValueError:
      pass
      except sr.RequestError as e:
      print("Could not request results from Google Speech Recognition service; {0}".format(e))
      return None
      def play_instruction():
      instruction = get_instruction()
      print(instruction)
      if instruction is not None and "play" in instruction:
      song = instruction.replace('play', "")
      talk("Playing " + song)
      pywhatkit.playonyt(song)
      elif instruction is not None and 'time' in instruction:
      time = datetime.datetime.now().strftime('%I:%M %p')
      talk('The current time is ' + time)
      play_instruction()

  • @MasterTarun-xl2sk
    @MasterTarun-xl2sk Рік тому +1

    Bro error line 65 play_jarvis
    Error line 35 in play_jarvis instruction = input_instruction
    Error line 31 in input_instruction return instruction
    Pls help bro

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому +1

      Hi
      Based on the error message you provided, it seems that you are encountering an error in a Python program or script related to creating a virtual assistant. The specific error is occurring on line 65 of the play_jarvis function, which is being called from line 35 in the play_jarvis function.
      Furthermore, there is an error on line 31 within the input_instruction function, where it attempts to return the value of the instruction variable.
      To troubleshoot the issue, you can examine the code surrounding these lines and look for any syntax errors or potential issues with variable assignments or function calls. Additionally, check if the necessary modules or libraries are imported correctly.
      If you are looking to expand your knowledge further, we invite you to explore our other courses in the description box.

  • @Billionaire-m2h
    @Billionaire-m2h Рік тому

    please send source code

  • @premsaireddy4903
    @premsaireddy4903 Рік тому +1

    the code is not running

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому

      Hi
      You can try this one:
      import speech_recognition as sr
      import pyttsx3
      import pywhatkit
      import datetime
      r = sr.Recognizer()
      machine = pyttsx3.init()
      def talk(text):
      machine.say(text)
      machine.runAndWait()
      def get_instruction():
      try:
      with sr.Microphone(device_index=0) as source:
      print("Listening...")
      r.adjust_for_ambient_noise(source)
      speech = r.listen(source)
      instruction = r.recognize_google(speech)
      instruction = instruction.lower()
      if "jarvis" in instruction:
      instruction = instruction.replace('jarvis', "")
      print(instruction)
      return instruction
      except sr.UnknownValueError:
      pass
      except sr.RequestError as e:
      print("Could not request results from Google Speech Recognition service; {0}".format(e))
      return None
      def play_instruction():
      instruction = get_instruction()
      print(instruction)
      if instruction is not None and "play" in instruction:
      song = instruction.replace('play', "")
      talk("Playing " + song)
      pywhatkit.playonyt(song)
      elif instruction is not None and 'time' in instruction:
      time = datetime.datetime.now().strftime('%I:%M %p')
      talk('The current time is ' + time)
      play_instruction()

  • @tanusreesaha9311
    @tanusreesaha9311 Рік тому

    hi,can u help me for one issue?
    actually the speech recognization is not happening.it is not taking input and also None output i am getting only.
    import speech_recognition as sr
    import pyttsx3
    import pywhatkit
    import datetime
    import pyaudio
    r = sr.Recognizer()
    machine = pyttsx3.init()
    def talk(text):
    machine.say(text)
    machine.runAndWait()
    def input():
    try:
    with sr.Microphone(device_index = 0) as origin:
    print("listening")
    print((sr.Microphone.list_microphone_names()))
    speech = r.listen(origin)
    instruction = r.recognize_goggle(speech)
    instruction.lower()
    if "jarvis" in instruction:
    instruction = instruction.replace('jarvis', "")
    print(instruction)
    except:
    pass

    def play_instruction():
    instruction = input()
    instruction = None

    print(instruction)
    if instruction is not None and "play" in instruction:
    song=instruction.replace('play', "")
    talk("playing" + song)
    pywhatkit.playonyt(song)

    elif instruction is not None and 'time' in instruction:
    time = datetime.datetime.now().strftime('%I: %M%p ')
    talk('current time' + time)

    play_instruction()

    • @Rj-1407
      @Rj-1407 Рік тому +1

      Me too bro, The input and output are not speeches

    • @SimplilearnOfficial
      @SimplilearnOfficial  Рік тому

      There seem to be a few issues with your code that might be causing the speech recognition to not work properly.
      1. recognize_goggle should be recognize_google: The method for recognizing speech is called recognize_google (with one 'o'), not recognize_goggle.
      2. input function is a built-in function in Python: You should avoid naming your own functions with the same name as a built-in function in Python. In this case, the input function you defined is hiding the built-in input function.
      3. You are setting the value of instruction to None in the play_instruction function: In the play_instruction function, you are setting the value of instruction to None before checking if it is not None and executing some code. This means that the code inside the if block will never execute. You should remove the line instruction = None in the play_instruction function.
      Here is a modified version of your code that should work better:
      import speech_recognition as sr
      import pyttsx3
      import pywhatkit
      import datetime
      r = sr.Recognizer()
      machine = pyttsx3.init()
      def talk(text):
      machine.say(text)
      machine.runAndWait()
      def get_instruction():
      try:
      with sr.Microphone(device_index=0) as source:
      print("Listening...")
      r.adjust_for_ambient_noise(source)
      speech = r.listen(source)
      instruction = r.recognize_google(speech)
      instruction = instruction.lower()
      if "jarvis" in instruction:
      instruction = instruction.replace('jarvis', "")
      print(instruction)
      return instruction
      except sr.UnknownValueError:
      pass
      except sr.RequestError as e:
      print("Could not request results from Google Speech Recognition service; {0}".format(e))
      return None
      def play_instruction():
      instruction = get_instruction()
      print(instruction)
      if instruction is not None and "play" in instruction:
      song = instruction.replace('play', "")
      talk("Playing " + song)
      pywhatkit.playonyt(song)
      elif instruction is not None and 'time' in instruction:
      time = datetime.datetime.now().strftime('%I:%M %p')
      talk('The current time is ' + time)
      play_instruction()
      I hope this helps! Let me know if you have any further questions.