Make a Voice Assistant with Python

Поделиться
HTML-код
  • Опубликовано: 15 июл 2024
  • We make our own virtual voice assistant using simple Python packages that lets you control your computer with Python!
    The power of Python packages continues to amaze me. We were able to make a simple virtual assistant that was able to track tasks, open programs, and much more!
    Code: github.com/Jalsemgeest/Python...
    Download FFMPEG: ffmpeg.org/download.html
    Thanks for watching! ❤️
    Discord: / discord
    Timestamps:
    0:00 Intro
    0:11 How to make the project yourself?
    0:38 Thought process
    1:05 Speech Recognition
    1:50 Speech Recognition Code
    3:36 Speech Recognition Example
    4:06 Text to Speech
    5:40 Text to Speech Code
    10:25 Text to Speech Example
    11:06 Make the assistant to do something
    12:06 Assistant example
    13:34 Adding a keyword to listen
    14:42 Keyword example
    15:04 Outro
    #python #coding

Комментарии • 121

  • @footprint_arts
    @footprint_arts 3 месяца назад +2

    The process was quite interesting, it shows that you just have to be curious enough😅❤ To get some things done

    • @jakeeh
      @jakeeh  3 месяца назад

      Absolutely! Curiosity and enough poking around is often all it takes :)

  • @user-pb2ti8wz5p
    @user-pb2ti8wz5p 2 месяца назад +1

    please make more this type of video great work keep it up man !!!!!

    • @jakeeh
      @jakeeh  2 месяца назад +1

      Thank you so much! ❤️ / Jake

    • @xspydazx
      @xspydazx 25 дней назад

      its nice to see the discovery process , (without focussing to much on it .... share the issues along the way ...as long as it works in the end !! this is the learning process...

  • @unknown__Amxn
    @unknown__Amxn 11 месяцев назад +3

    Amazing 😯♥️

    • @jakeeh
      @jakeeh  11 месяцев назад +1

      Thank you! Happy you enjoyed the video! 🙂

  • @auger2012
    @auger2012 11 месяцев назад +4

    Interesting video and nice to see thought process. 1 probably obvious question is the hard drive getting full up of MP3 + wave files or are they just temp files?

    • @jakeeh
      @jakeeh  11 месяцев назад +6

      Thanks for the comment! That’s a great question. It actually shouldn’t be a problem as each time the assistant responds it overwrites the previous version. So you will have at most one MP3 and one WAV file. I probably could have mentioned that 😅

  • @user-ui8mw3cx6m
    @user-ui8mw3cx6m 7 месяцев назад

    tnx you

    • @jakeeh
      @jakeeh  7 месяцев назад

      No problem!

  • @sanatannnii
    @sanatannnii 6 месяцев назад

    Very Nice 🙂

    • @jakeeh
      @jakeeh  6 месяцев назад

      Thanks 😊

  • @enzanto
    @enzanto 9 месяцев назад

    an up and coming youtuber you say? I better like and subscribe then!
    my suden ideas:
    1. as i am currently building a Discord bot. I thought that this, with discord should be cool.
    2. make a voice assistant to control my smarthome.
    3. make a voice asisstant to do tasks on my pc.

    • @jakeeh
      @jakeeh  9 месяцев назад

      Thanks for the support!
      There are a ton of ways you can use this. It’s a great time to be a programmer :)
      Consider joining our Discord community as well. I always love to hear about what projects people are working on!

  • @ItsMe-xm1nx
    @ItsMe-xm1nx 11 месяцев назад +3

    nice video

    • @jakeeh
      @jakeeh  11 месяцев назад

      Thank you :)

  • @electronicsacademy2D2E29
    @electronicsacademy2D2E29 5 месяцев назад

    This video aligns with my current interests, thank you very much. Google speech recognition service is not free beyond 60 minutes per month, I think. So how are you managing past that ? Are you using any other free options ?

    • @jakeeh
      @jakeeh  5 месяцев назад +2

      Happy to help! I have only used this for small amounts of time, so I haven’t hit the 60 minutes before. That said, I’m not entirely sure of good free alternatives. With a quick search I did find a few that seem promising, but I can’t vouch for any myself at this time.

  • @astro5694
    @astro5694 11 месяцев назад +1

    Another super creative video, nice job! Do you have a discord community set up?

    • @jakeeh
      @jakeeh  11 месяцев назад +1

      Thank you!
      I don’t have a discord community yet, but I plan to have one set up in ~1 week once I’m back home from vacation. I’ll reply here to let you know :)

    • @jakeeh
      @jakeeh  10 месяцев назад +1

      Just created my discord - I added a link to the video description :)

    • @astro5694
      @astro5694 10 месяцев назад

      @@jakeeh thanks for the update!

  • @renlog7755
    @renlog7755 11 месяцев назад +2

    pyttsx3 is really good at tts imo it does sound a bit more robotic but its easier to use it doesnt make a file or anything(that is an option tho)

    • @jakeeh
      @jakeeh  11 месяцев назад +1

      I haven’t used pyttsx3 before but that sounds like a great option! I was just happy to find something so quickly. It’s amazing what’s available to us nowadays :)

    • @drak4188
      @drak4188 9 месяцев назад +1

      @@jakeeh I second this it's what I use much better than letting Google know what your up to 😁

    • @jakeeh
      @jakeeh  9 месяцев назад +1

      I’ll be sure to take a look at pyttsx3. Thanks for the suggestions :)

    • @xspydazx
      @xspydazx 28 дней назад

      Yes for text to speech it's fast !! So for output it's great 👍

    • @xspydazx
      @xspydazx 28 дней назад

      @@drak4188 yes I was wondering , is it being converted online ? (Perhaps disconnect the internet and test it ? )

  • @tubaguy0
    @tubaguy0 8 месяцев назад

    Skippy the Magnificent!

    • @jakeeh
      @jakeeh  8 месяцев назад

      Is that the name of your personal assistant? :)

    • @tubaguy0
      @tubaguy0 8 месяцев назад +1

      @@jakeeh no sorry, you mentioned putting York favorite fictional AI in the comments. Skippy is from the Expeditionary Force series by Craig Alanson. Highly recommended!

    • @jakeeh
      @jakeeh  8 месяцев назад

      Oh that's awesome! I'll have to check it out :)

  • @kristiananhj8140
    @kristiananhj8140 2 месяца назад +1

    Is it possible to make a Voice Assistant (on windows) where you are not local administrator ?
    On work pc I'm not local admin, but got Python installed and can get modules, but can't install FFMPEG.

    • @jakeeh
      @jakeeh  Месяц назад

      Hey, it might not be possible to install FFMPEG without admin controls unfortunately. You might be able to find an alternative though can can work with the wav files instead though :)

  • @twberly
    @twberly 6 месяцев назад

    If you're still seeing comments, whenever I run the code it does say "Listening for commands..." but doesn't pick up my voice. Any fix : )

    • @jakeeh
      @jakeeh  6 месяцев назад +1

      I'm always checking comments :)
      You should try adding a couple of print statements after the recognizer and "audio = " line. See if you end up getting there or if you're getting stuck there and it's just not taking input.
      Are you seeing any error or just no output outside of the "Listening for commands..."?

  • @doddianil6946
    @doddianil6946 5 месяцев назад +1

    is it possible store user voice and next use voice assistant live voice compare with stored voice the both voice are match the voice assistant respond for user command other wise not respond ? like voice biometric system plz explain

    • @jakeeh
      @jakeeh  5 месяцев назад

      Oh that’s a fun idea! As far as I know, none of the current packages we’re using in this project are capable of doing that. There might be some packages that are capable of that though. Voice biometrics is not a super thing to solve with any high level of accuracy, so it is probably trickier than you might imagine

    • @doddianil6946
      @doddianil6946 5 месяцев назад

      @@jakeeh I know it's funny but my project is that creating authorised voice assistant it means it's respond only owner of the device commands only.but don't know how the machine identify it's owner voice if you know anything about that help mee 😍

    • @jakeeh
      @jakeeh  5 месяцев назад

      Yeah, it’s a cool project for sure. 👍
      Unfortunately biometrics is a complicated problem, so there doesn’t seem to be too many free resources. I did find this GitHub project (github.com/Raymo111/voiceprint) but it will require you to train a model using it.

  • @xspydazx
    @xspydazx 28 дней назад

    anything that works is good !!
    the hardest thing is the ffmpeg pesky thingy

    • @jakeeh
      @jakeeh  28 дней назад +1

      ffmpeg can be annoying to work with at first but it can be super powerful if you get used to it :)

    • @xspydazx
      @xspydazx 28 дней назад

      @@jakeeh I got the speech in , image in , text in ...
      I got the speech out , the text out , (no diffusion yet) ..
      I would like the video in ! ... Perhaps to pictures to description ...
      I would like sound in to description (like that's the sound of a man ... Driving a car ? ) .. and sound out , generate the sound of a dolphin ? ...
      So this version of speech in is actually not bad .. still a playoff between this and whisper ... But this has enabled me to have the microphone live instead so it's great 👍

    • @jakeeh
      @jakeeh  25 дней назад

      Yeah, that would be an amazing tool if you can get all that working! Diffusion in my experience takes a while, although I don’t have an Nvidia GPU so it’s just using CPU.

    • @xspydazx
      @xspydazx 25 дней назад +2

      @@jakeeh the audio diffusion is actually quite quick ... i have the stable diffusion for imgae also but i think it was quite heavy ... i think there maybe a different option... i think the stable diffusion method is actually bad ... not for soun but for vison ... its too heavy and too many parts !

  • @Rmanvideo
    @Rmanvideo 10 месяцев назад

    interesting

    • @jakeeh
      @jakeeh  9 месяцев назад

      Thanks!

  • @VK-qh6pr
    @VK-qh6pr 9 месяцев назад +4

    Wonder if someone put together already an local jarvis like assistant with python....

    • @jakeeh
      @jakeeh  9 месяцев назад +2

      Yeah I do wonder that! Maybe a fun personal project if you can hook it up to your house lights and stuff :)

  • @Evermysticdesigns
    @Evermysticdesigns 19 дней назад

    Hey maybe you can help me , im building a droid and i want him to communicate with ai and deliver it back to me using his custom made voice... is this possible ?

    • @jakeeh
      @jakeeh  19 дней назад

      It should be possible, yeah. You’ll need to investigate voice mimicking. I think all you would need to do is take the input, run it through a model of your choice, and then get the string as output and run it through your custom voice.
      If you want it be able to be smart based on the response though, that would be much more difficult though. You’d need custom models, that’s something big companies are still figuring out

  • @AbbasAli-hg7dn
    @AbbasAli-hg7dn 7 месяцев назад +1

    What if i want to search in TXT or PDF file alternative of wikipedia 🤔

    • @jakeeh
      @jakeeh  7 месяцев назад

      Yeah you could definitely do that. There is a Wikipedia pip package you could install to search Wikipedia easily.
      A text file you would just need to read the text from. Ideally separate it per new line and then search for keywords in each line until you find a match. :)

    • @AbbasAli-hg7dn
      @AbbasAli-hg7dn 7 месяцев назад

      @@jakeeh can you please make a video about it like you want to search in your only txt or PDF file

    • @jakeeh
      @jakeeh  7 месяцев назад

      I can probably make a quick video to show something like that. No guarantee on a release date though. :)

    • @AbbasAli-hg7dn
      @AbbasAli-hg7dn 7 месяцев назад +1

      @@jakeeh That will be great. Thanks 👍

  • @ibrahimakhalildiallo9882
    @ibrahimakhalildiallo9882 5 месяцев назад

    hi JakEh, thank you for the video. I tried it but I get an error.
    ImportError: cannot import name 'AudioSegment' from 'pydub'
    how can I import Audiosegment from pydub please ?

    • @akankshayadav3087
      @akankshayadav3087 5 месяцев назад +1

      there might be possibility that you havn't installed pydub and that could be the possible reason for getting this error and if you have already installed pydub then try to upgrade as "pip install --upgrade pydub".

    • @jakeeh
      @jakeeh  5 месяцев назад +1

      I think @akankshayadav is right. Try to install that and see if you get a different result, if not post back here or in the discord :)

    • @ibrahimakhalildiallo9882
      @ibrahimakhalildiallo9882 5 месяцев назад

      @@akankshayadav3087 Thank you so much. But I already did it and was still Error 😕

    • @ibrahimakhalildiallo9882
      @ibrahimakhalildiallo9882 5 месяцев назад

      @@jakeeh Thank you for your answer. But I already tried it and nothing

    • @jakeeh
      @jakeeh  5 месяцев назад

      Would you mind posting the stack trace and maybe a picture of your directory into the Discord? Without more information it's difficult to help out :)

  • @FilmSpecs00
    @FilmSpecs00 Месяц назад

    The next step in my process would be to have the Ai activate on the trigger word, like siri and Alexa do, but I always find I have to run the program manually again after I exit the Ai and it stops responding to commands and such after a few minutes of in-activity. I don't want it to continuously listen as to not take up space but I need it to activate on command🤷🏼

    • @jakeeh
      @jakeeh  Месяц назад

      Great point! I think what you could do would be similar to what many home assistants do which is have a small lightweight program that runs all the time just listening for a single word or a stream of words. Then it saves that if it heard the keyword at the start, like “Alexa”. Then it executes another separate program that does the heavy lifting of understanding the audio and it returns a response.
      Still not super ideal, but you’ll need something running to listen :)

    • @xspydazx
      @xspydazx 28 дней назад

      @@jakeeh I think that you need to have a wake (two words) ... Like "hey Alexa" ... The extra word enable for less confusions with other potential simple words which may activate it by accident ... .. so like hay Jarvis ... Or hey computer ... Is perfect ...

  • @SSBO727
    @SSBO727 6 месяцев назад

    I get an error while installing audiosegment library.... Could you please help me

    • @jakeeh
      @jakeeh  6 месяцев назад

      Hey Sreesanjanabose,
      What error did you see when you tried installing it?

    • @SSBO727
      @SSBO727 6 месяцев назад

      @@jakeeh can I mail you sir..... I can share with you the screenshot of the error ... It said it needs visual c++.... Which i downloaded still can't crack it

    • @jakeeh
      @jakeeh  6 месяцев назад

      Feel free joining the discord! You're welcome to post there asking for help and I and others can see if we can help out :)

  • @railey_r6603
    @railey_r6603 4 месяца назад

    Can one fit this tech into a toy doll or toy snimal

    • @jakeeh
      @jakeeh  4 месяца назад

      In theory yes. You would need some kind of small computer capable of running this and a mic and set of speakers. But that should be possible.
      This would also need an internet connection too though. I do have another video where you could do it all offline though.

  • @minecraftmacjava123
    @minecraftmacjava123 Месяц назад

    when I did pip install winsound it didn't work it said, ERROR: Could not find a version that satisfies the requirement winsound (from versions: none)
    ERROR: No matching distribution found for winsound
    ERROR: Could not find a version that satisfies the requirement winsound (from versions: none)
    ERROR: No matching distribution found for winsound

    • @jakeeh
      @jakeeh  Месяц назад

      Which python version are you using?

    • @minecraftmacjava123
      @minecraftmacjava123 Месяц назад

      @@jakeeh never mind im using mac but can it still work with mac

    • @jakeeh
      @jakeeh  Месяц назад

      Yeah there should be a way to make it work for Mac that does the same thing that Winsound does :)

    • @minecraftmacjava123
      @minecraftmacjava123 Месяц назад

      @@jakeeh can you make a small tutorial on that, please?

    • @jakeeh
      @jakeeh  Месяц назад

      @minecraftmacjava123 I can look into it, although I’d suggest asking in the Discord to see if anyone else has tried this on a Mac and has any luck :)

  • @sanatannnii
    @sanatannnii 6 месяцев назад

    Can i try it

    • @jakeeh
      @jakeeh  6 месяцев назад

      You sure can! The code is in the link in the description to my Github :) Feel free to just download that and give it a run :)

  • @elierh442
    @elierh442 11 месяцев назад +1

    Add gpt-4 and you have Google assistant 2.0!

    • @jakeeh
      @jakeeh  11 месяцев назад +1

      Absolutely! With all the free tools it’s amazing the power when you mash a few things together :)

    • @drak4188
      @drak4188 9 месяцев назад +1

      @@jakeeh you can but you need an API from your Chatgpt login plus it costs you not much but it still is a cost

  • @bhavanashetty385
    @bhavanashetty385 5 месяцев назад

    Can we implement this as hardware

    • @jakeeh
      @jakeeh  5 месяцев назад

      I think you probably could if you have a raspberry pi or something + a mic.
      What were you hoping to make?

    • @bhavanashetty385
      @bhavanashetty385 5 месяцев назад

      @@jakeeh a voice assistant which can project also.

    • @bhavanashetty385
      @bhavanashetty385 5 месяцев назад

      It's similar to what you have done but I want to make that instead of computer

    • @jakeeh
      @jakeeh  5 месяцев назад

      I'm not sure I understand exactly what you want to make. But try to do some searching online and you might be able to find pieces of what you want and then you just need to piece them together :)

  • @auger2012
    @auger2012 11 месяцев назад

    Holo Lili 😊

    • @jakeeh
      @jakeeh  11 месяцев назад +1

      Did you name your assistant Lily?! :)

    • @auger2012
      @auger2012 11 месяцев назад

      @@jakeeh at the end of the 90's there was a TV series called earth final conflict. One of the characters called Augur fancied a women who wasn't available/interested so he build a virtual holographic assistant with her image and voice.
      It got pregnant and gave birth to a new baby AI if I remember correctly.
      Something I've never forgotten lol

    • @jakeeh
      @jakeeh  11 месяцев назад

      Oh wow! I grew up in the 90s but I certainly missed that one :)

  • @tharakahasintha6646
    @tharakahasintha6646 8 месяцев назад

    can you give me sourse code ?

    • @jakeeh
      @jakeeh  8 месяцев назад

      Just added it to the description. Thanks for the heads up that it wasn’t there yet :)

  • @sbtaruncreations608
    @sbtaruncreations608 3 месяца назад

    Source code sir?

    • @jakeeh
      @jakeeh  3 месяца назад

      There’s a link in the description to the GitHub for the code :)
      Thanks for your comment!

  • @dhruvpatel8890
    @dhruvpatel8890 29 дней назад

    Please Send Me this Code File Please

    • @jakeeh
      @jakeeh  29 дней назад

      There’s a link in the description with the code :)

  • @Nonsensecal
    @Nonsensecal 8 месяцев назад

    I copy pasted the code into VSC but it doesn't work. Is there anything else I need to do

    • @jakeeh
      @jakeeh  8 месяцев назад

      Did you install the PIP packages for the project? If not, you’ll need to do that. Otherwise, if you could reply with what error you’re seeing when you’re running the code that would be helpful :)

    • @Nonsensecal
      @Nonsensecal 8 месяцев назад

      @@jakeeh It doesn't come up with a problem so I believe I've installed all the packages. This is the error I'm getting:
      PS C:\Users\kiki__871k8t> & C:/Users/kiki__871k8t/AppData/Local/Programs/Python/Python312/python.exe c:/Users/kiki__871k8t/Downloads/assistant.py
      C:\Users\kiki__871k8t\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
      warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
      This has been building a virtual assistant with Python
      C:\Users\kiki__871k8t\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
      warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
      Traceback (most recent call last):
      File "c:\Users\kiki__871k8t\Downloads\assistant.py", line 75, in
      respond("This has been building a virtual assistant with Python")
      File "c:\Users\kiki__871k8t\Downloads\assistant.py", line 31, in respond
      sound = AudioSegment.from_mp3("response.mp3")
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\kiki__871k8t\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydub\audio_segment.py", line 796, in from_mp3
      return cls.from_file(file, 'mp3', parameters=parameters)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\kiki__871k8t\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydub\audio_segment.py", line 728, in from_file
      info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\kiki__871k8t\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
      res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\kiki__871k8t\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
      File "C:\Users\kiki__871k8t\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child
      hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      FileNotFoundError: [WinError 2] The system cannot find the file specified

    • @jakeeh
      @jakeeh  8 месяцев назад

      It looks like you don’t have ffmpeg installed which is a program that helps convert files from one form to another. In the video it’s what the package that converts the voice file from mp3 to a wav.
      I’ll add a link to the description for where to download it :)

    • @Nonsensecal
      @Nonsensecal 8 месяцев назад

      @@jakeeh I've installed it but now it's saying that speech_recogniton, gtts, pydub and pyautogui could not be resolved when I've installed all of them

    • @jakeeh
      @jakeeh  8 месяцев назад

      Are you using the same version of Python to run it as you installed the packages with pip? If you’re not sure, make sure you run it with ‘python -m pip install pyautogui’ then ‘python myscript.py’.

  • @marcin4xm
    @marcin4xm 6 месяцев назад

    Yee but not internet acces then this all will not work

    • @jakeeh
      @jakeeh  6 месяцев назад

      That’s right. We’re using a couple packages that call services online. So this won’t work if you’re offline.

    • @JeromeDemers
      @JeromeDemers 5 месяцев назад

      Yeah but I think Alexa, Siri, google, ChatGPT all need internet anyway. I think Apple Watch can work offline. Or without the phone.

    • @jakeeh
      @jakeeh  5 месяцев назад

      That's true! Most usually need an active internet connection. This is because they don't have any kind of local model that can interpret speech, so the audio is sent to a server to compute the response/action.
      That being said, there are some 'mini'-models as you described where the model that does the interpreting is small enough to be on the device. It's certainly possible to make one of those yourself, but it's not going to be very easy :)

  • @mansafamara
    @mansafamara 10 месяцев назад

    hey jake, i love your energy in your videos. do you have a twitter (x) or an email where we can correspond? i’d love to chat.

    • @jakeeh
      @jakeeh  10 месяцев назад

      Hey 👋
      I actually have a Discord where you’re welcome to join and chat :) A link should be in the description of the video. I do have Twitter as well, but I’m less active there, it’s @JakeEhTv.