Python Jarvis: Wake Word Detection - Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ต.ค. 2024
  • Python Jarvis tutorial episode 2 - Today we will add an on device wake word to our new voice assistant program. At the end you will be able to use one of a select choice of words to begin the speech-to-text function.
    Links mentioned in the video:
    Pypi PVPorcupine (1.9.5) webpage: pypi.org/proje...
    PicoVoice Website: picovoice.ai/

ความคิดเห็น • 54

  • @run4ik866
    @run4ik866 11 หลายเดือนก่อน +1

    Its awesome! My voice assistent has gotten better, thanks to you!

  • @AarushDutta-v9u
    @AarushDutta-v9u 11 หลายเดือนก่อน

    Thank you so much! This helped me a lot! I've been searching the internet for 6 months and this saved me!

  • @decod3
    @decod3 2 ปีที่แล้ว +3

    You deserve a ton of subscribers bro.

  • @Nelson_Bazzard
    @Nelson_Bazzard ปีที่แล้ว +3

    thank you, your tutorials are very helpful i also enjoy your content!

    • @S-Technology
      @S-Technology  ปีที่แล้ว +1

      Thank You! I’m glad you found them helpful.

  • @shivamshsr-345
    @shivamshsr-345 ปีที่แล้ว +2

    Bro you need deserve more subs

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      Thank you. Just trying my best.

  • @devadaths3859
    @devadaths3859 ปีที่แล้ว +1

    Thank you sirrr
    I was looking for aa wake up word program you are greattt

    • @S-Technology
      @S-Technology  ปีที่แล้ว +1

      Thank you. I hope it helps.

  • @yosuto908
    @yosuto908 ปีที่แล้ว +1

    can you make him appear on your screen as a image or as a gif? (not thorough Google tho)

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      Yeah. I use PyGame to make a animation for him talking.
      I have a semi recent demo of what he looks like here: th-cam.com/video/yAKlr1ZtAng/w-d-xo.html
      And a tutorial of how I made it here: th-cam.com/video/xNksGWKJ1fI/w-d-xo.html

  • @mohdismailmohtar5179
    @mohdismailmohtar5179 11 หลายเดือนก่อน

    Thank you bro. You Are The Man.

  • @zbeb118
    @zbeb118 ปีที่แล้ว +1

    Hello, great work, do you have an idea how I can implement this feature:
    Instead of saying: "Jarvis" and waiting for the wake word to get detected then saying the command, you simply say "Jarvis what time is it" and it answers.
    Thanks

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      I don't believe you can take the audio received from Pvporcupine and send it straight to the Speech Recognition function.
      A very basic way would be to not have a wake word, but use a local running engine for the Speech to Text. . Then everything you say doesn't get stored in a google server, and your not constantly using the internet.
      Then just nest some loops in the code.
      if "Jarvis" in text_heard:
      if "what time is it" in text_heard:
      Give time code here
      elif "what day is it" in text_heard:
      Give date code here

    • @zbeb118
      @zbeb118 ปีที่แล้ว

      @S-Tech yeah, kinda disappointed as I want to use pvporcupine for its accuracy, ill try and contact them to look for a solution, thanks

    • @zbeb118
      @zbeb118 ปีที่แล้ว

      @S-Tech so I contacted them and they said the model used doesn't listen to what I say afterward, would you happen to know one that does? The issue with the speech_recognition library is that its not accurate and misunderstands the wake word

    • @S-Technology
      @S-Technology  ปีที่แล้ว +1

      Look into a library called “vosk”. It’s on device speech recognition. I stopped using the speech recognition library months ago and use that now.
      The only downside is that to get really accurate results you need to use the larger model and that loads about 6 Gbs into the memory when active. So if you have a small system (8 Gbs of RAM) it doesn’t work. If you saw the video where i disassembled the mini pc, that’s why I added more RAM.
      It picks up the word Jarvis pretty well.

    • @zbeb118
      @zbeb118 ปีที่แล้ว +1

      @@S-Technology got it, thanks for the help

  • @randallbenson6435
    @randallbenson6435 ปีที่แล้ว +1

    Thank you for this tutorial, and thank you for no GitHub...seriously! It's helping me learn python more. On that note, i've hit a big snag and I can't seem to figure it out. I am seemingly getting this error "||PaMacCore (AUHAL)|| Error on line 2499: err='-50', msg=Unknown Error" before the "Hotword detected..." prints out. It only throws the error when I say the hotword. Research implies there is something off with the audio driver, but I'm not sure. I should note I am using a Mac. Anyway, any help would be appreciated...this is a real exciting project.

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      Thank you.
      Hmm. What are you using for the audio driver? Are you using Pyaudio or something else? I would also try a different wake word to see if it gives the same results.

    • @randallbenson6435
      @randallbenson6435 ปีที่แล้ว

      @@S-Technology I’m using pyaudio. Even made sure Portaudio was installed first then pyaudio. Reinstalled both several times. All my research has led to it being a driver issue, but I’m on a mac that is current on its updates. Latest pyaudio, portaudio, python, etc. i am using the lates pvporcupine too, but have my api key set. That part seems to be working. I really think it’s pyaudio somehow but im not sure. I may try it on another computer.

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      @@randallbenson6435 There was a random bug that would happen with pyaudio on windows where it wouldn't always install correctly. You would need to install additional binaries that are specific to your python version and windows OS specs. Maybe it's something similar.
      I did find something about an issue installing Pyaudio on M1 macs. I'm sure you probably already saw it. But if not, maybe it's helpful. discussions.apple.com/thread/252638887

  • @ahmedakmal1545
    @ahmedakmal1545 ปีที่แล้ว

    Is there a way i can add a custom word? A tutorial on that would be so great.

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      I believe you can with the newer version of picovoice. I think you can create your own or access ones others have created. You have to use their online service for it and use an API key to access their databases. I wanted something that was completely offline, so the options are limited.

  • @ali3nshe
    @ali3nshe ปีที่แล้ว

    hi I have 2 problems. The first is on the last line of code it says there is something wrong with putting "main()" and my second problem is it says "create() missing 1 required positional argument: access_key" for the porcupine = pvporcupine.create(keywords=["jarvis"]). What am I doing wrong?

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      Are you using the version of pvporcupine in the video? The newer versions require an account and you use the access key they supply you. You can do things like make your own hot words that way, but I don’t think they offer a free version with that.
      The older version is limited but free.
      And the main() function is named the same? Is one Main() or some other typo?

    • @ali3nshe
      @ali3nshe ปีที่แล้ว

      @@S-Technology i cant tell if I’m using your or not haha but I went to their python page and turns out I was reading the old version. Should i make an account they say that it’s free? Also for the main problem yes it’s the same main as the one I typed first but it’s still showing error

    • @AlexYazanGames
      @AlexYazanGames ปีที่แล้ว

      how do i use the older version?@@S-Technology

  • @TheScorch78
    @TheScorch78 ปีที่แล้ว

    Hi, just wanted to ask if you know why I would be getting an error that says " invalid sample rate " inside the audio_stream function
    my rate = porcupine.sample_rate so im not sure what is the issue

    • @S-Technology
      @S-Technology  ปีที่แล้ว +1

      That function has to do with opening a stream with PyAudio. Are you using a windows machine? If so, it's possible PyAudio might not be installed correctly. There's been an issue with pip installing PyAudio in windows for awhile. I think I covered it in the first Jarvis DIY video.

    • @TheScorch78
      @TheScorch78 ปีที่แล้ว

      @@S-Technology I'm actually using a raspberry pi

    • @TheScorch78
      @TheScorch78 ปีที่แล้ว

      @@S-Technology Have you ever encountered an issue that says "AssertionError: Audio source must be entered before listening, see documentation for AudioSource; are you using source outside of a with statement?" when running you code? At the moment, my wake word works fine but when it enters the takeCommand() function, it will give the said error

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      @@TheScorch78 In the takeCommand() function do you have your microphone as a source (Example: with sr.Microphone() as source: )
      With a pi I believe you may need to make sure the microphone you are using is set as the default audio input device. You can also dedent the try & except below the with loop. (Like shown in answer here: stackoverflow.com/questions/65769263/assertionerror-audio-source-must-be-entered-before-listening)
      Both ways work on Windows, not sure about Rasbian.

    • @TheScorch78
      @TheScorch78 ปีที่แล้ว

      @@S-Technology yes, I have made my microphone input the default on /home/pi/ .asoundrc, and I have tried dedenting the try & except loop, but it doesnt seem to work on the pi :(

  • @Thor_Odinson100
    @Thor_Odinson100 ปีที่แล้ว +1

    thank's bro really great work : )

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      Thank you. I hope it was useful.

  • @soumaorokante4590
    @soumaorokante4590 ปีที่แล้ว

    Thanks for the video, I ve got a list of errors that pop up when implementing the code:
    -Cannot connect to server socket err = No such file or directory
    -cannot connect to server request channel
    -jack server is not running or cannot be started
    -jackShmReadWritePtr: :~JackShmReadWritePtr - Init not done for -1, skipping unlock
    Can you help with this please

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      Are you using Ubuntu? I’m not to familiar with that.
      For some reason you are trying to create a socket for a server connection and it’s failing. I think the “jack server” is some kind of sound device. Maybe look at this link: askubuntu.com/questions/557906/problem-starting-jack-server-jack-server-is-not-running-or-cannot-be-started

  • @kadaliakshay6770
    @kadaliakshay6770 7 หลายเดือนก่อน

    Can i please have the source code for this video please (if possible)

  • @xmxkxmd
    @xmxkxmd ปีที่แล้ว

    is it
    a open sourse prjoect? Can i get link on github?

    • @S-Technology
      @S-Technology  ปีที่แล้ว +1

      I didn’t make a GitHub for it. Sorry

  • @OEpicoCosmos
    @OEpicoCosmos ปีที่แล้ว

    i dont know if i make something wrong, but its not working

    • @S-Technology
      @S-Technology  ปีที่แล้ว +1

      Is it giving an error code of some kind? What’s not working?

    • @OEpicoCosmos
      @OEpicoCosmos ปีที่แล้ว

      @@S-Technology it was my bad, i forgot to put the "main()" in the end 🤡 sorry

    • @OEpicoCosmos
      @OEpicoCosmos ปีที่แล้ว +1

      @@S-Technology but, my winsound dont work, im searching to see if there is any solution, it just dont play any sound
      edit: nevermind, find out

    • @S-Technology
      @S-Technology  ปีที่แล้ว +1

      I've done that many times. It happens. haha
      Glad you got it working.

  • @AlexYazanGames
    @AlexYazanGames ปีที่แล้ว

    when i say jarvis he is still listening, can u help

  • @devinsh5892
    @devinsh5892 ปีที่แล้ว

    could you give a source code please

    • @S-Technology
      @S-Technology  ปีที่แล้ว

      The code is in the video. Are you wanting to just copy it? I’m confused.

    • @dxs_nightwolff
      @dxs_nightwolff 11 หลายเดือนก่อน

      ​@@S-Technology No, he wants to clone it. You know - that popular thing where you download code that's supposed to be free anyway.
      I'm confused - you want people to learn Python? Or you want to show people that you know Python? Or you simply want people to rewrite all that code and then share it anyway?

    • @S-Technology
      @S-Technology  11 หลายเดือนก่อน

      I’m aware of using git to clone projects.
      I don’t have a repository for this project.
      Python is free of course. But I’m not going to sit and hold people’s hands and do their homework for them. If you are just handed something you don’t learn it.
      Why such an attitude?

  • @TheIaTaI
    @TheIaTaI ปีที่แล้ว

    def wake_word() -> int:
    """
    Processes a single audio frame and returns the keyword index if detected, otherwise -1.
    Args:
    stream: Audio stream.
    porcupine: Porcupine instance.
    Returns:
    Keyword index if detected, otherwise -1.
    """
    porcupine = pvporcupine.create(keywords=['jarvis'])
    pa = pyaudio.PyAudio()
    # Open an audio stream for the wake word detector
    wake_word_stream = pa.open(rate=porcupine.sample_rate,
    channels=1,
    format=pyaudio.paInt16,
    input=True,
    frames_per_buffer=porcupine.frame_length)
    # Read a single audio frame from the stream
    pcm = wake_word_stream.read(porcupine.frame_length)
    # Convert the PCM data to a list of samples
    pcm = struct.unpack_from("h" * porcupine.frame_length, pcm)
    # Process the audio frame and return the keyword index
    return porcupine.process(pcm)
    def init_jarvis() -> None:
    """
    Initializes the Jarvis voice assistant and runs the main loop.
    Returns:
    None.
    """
    try:
    # Create a Porcupine instance with the Jarvis keyword
    # Main loop
    while True:
    # Listen for the wake word
    keyword_index = wake_word()
    I am trying to encapsulate the logic, inside the function and have the wake_word() inside the main while loop, however the word is not detected.