Python Voice Assistant Tutorial #9 - Waking the Assistant

Tech With Tim · Beginner ·🧠 Large Language Models ·6y ago

Key Takeaways

This video tutorial demonstrates how to create a wake keyword for a Python voice assistant, allowing users to trigger the assistant with a specific word or phrase, such as 'hey tim', using tools like Python and get_audio.

Full Transcript

hello everyone and welcome back to their Python voice assistant tutorials what I'm gonna be doing in this video is fixing a few bugs that have occurred from previous videos as well as adding a wake word to our assistant now this might be split into two parts depending on how long this takes me but what we're gonna be doing is making it so that we can say something like hey Tim or hey Google or hey botch or whatever we want and that will trigger the voice assistant to actually start listening for the command so we'll always be listening but it will only be listening for commands after we have that wake word which is what you guys were suggesting to me now before we move too far let's fix a few bugs so the first thing that I want to do is just go up and get audio here and this is what you guys have recommended and I don't know why I didn't do this to start when we returned said here I'm just gonna return said lower because that's gonna make it so we don't have to keep calling dealt lower every time we want to get the the value of text because we don't really care about the Capitals at all so what I'm gonna do now is just get rid of wherever I put down lower so like get audio down lower it don't don't need that get audio dot lower pretty much anywhere we have dot lower we don't need that anymore because we've just fixed that and saved us a bit of time now the next thing I'm gonna do is go into this get events function and change a bug that actually our friend here Doug pointed out to me in one of the comments section some of you guys have points them out as well but this one seems significant to me so that's why I'm kind of sharing him out here he was saying essentially that if our event falls in the afternoon the way that I've programmed get events is it will actually cut off the like the half an hour point if it starts at that time so if it doesn't fall directly on the hour and it starts at you know 12:30 or 1:30 or something like that it won't say the 30 aspect so we need to include that so to do that we're just gonna take this line here so plus start underscore time dot split at : 1 and add that to the end right here so inside this for loop inside this else and this first line here I'm gonna add that line so + start time dot split : at 1 now the reason this is happening is because I was just taking the hour aspect I wasn't taking the minute aspect which I need so this will add the minute aspect to that and that should be good for us now at least I've tested this and it did work so I'm hoping that this will be fine the way that we have it now ok so now that we've done that let's just do a quick test here and see if this is actually working so I'm just gonna run this what do I have on Wednesday at 1:00 p.m. to toriel 2:30 p.m. okay so there we got that now 2:30 p.m. so that is working and we are all good to go all right so now that we've done that what I'm gonna do is include this wake keyword so I'm gonna start by just creating a variable here at the bottom called Wake word or like awake I shall just say one my sect not way not week Wake equals they're going to put the string that we want to wake up with here in lowercase in this case I'm just gonna make mine hate Tim so if you say hey Tim then we'll be good to go and we will wake up so what are we gonna do now to get this working well we need to essentially put all of this inside of a while loop and start doing kind of it's slightly complex but we just need to always be listening see if we ever say hey Tim and if we do alert the user and then start looking through their next command for any of this so like write something down or asking about the events that we have so what I'm gonna do is I'm just going to make a while loop here let's say a while true like that and I'll take all this and indent that now what I'm gonna do is keep text equals get underscore audio but I'm gonna just do an if statement here and say if text dot count wake greater than one then what we'll do is we'll do all of this now I'm else we're just gonna say speak I am ready and then what I'm gonna do is say text equals get underscore audio one more time now let me explain how this is gonna work so what we're gonna do is we're gonna be constantly listening so always listening in this while loop now as soon as this picks up some kind of text so this get audio function which is all the way up here it will return that to text and then what we're gonna do is check if we said hey Tim now if we said hey Tim anywhere in that kind of blob of text that we got there what we'll do is we'll say tell the assistant to say I am ready after it says I'm ready it will wait for another command cuz so think about it like this right like we're talking maybe having having a conversation and all of a sudden I say hey Tim we wait a second and then it says I am ready okay and then you say what do I have on Wednesday and then it takes this text and it will process any command based off of that now I'm just gonna make one slight change here in this speak function so it's a speak please try again inside of for phrase what I'm gonna do is just change this to I didn't or I don't understand rather than try again because saying try again will prompt the user to want to just say the command again rather than start with hate Tim which is not exactly what we want so anyways I think this should be okay for now to start testing with there might be a few things I need to change after this let me just look on my other screen to make sure I didn't make an error okay what I'm actually gonna do is just add another text another print statement in here just says listening so that we know every time that this runs and we get an idea of kind of how this is working so what I'm gonna do is bring this up here and run this and then see if this is working for us okay so it started we're listening you can hear that I'm talking here and nothing's happening with the with the voice so I'm just gonna turn my volume up so you guys can hear okay so I just ran this and realized I've made a critical error here instead of saying greater than one I need to say greater than zero otherwise that's like never gonna work unless you say hey Tim twice I'm sure you guys probably caught that but anyway so let's just change that let's run it again you can see this is what happened last time okay so I need to run this okay so we're just talking here pretend we're having conversation all of a sudden I say hey Tim I am ready okay it says I'm ready what do I have on Tuesday um who invents on this day si si si 21 10:10 a.m. si si si 21 10 11 1:00 p.m. 21:05 11 5:30 a.m. atm 15:40 lectures at 7:00 p.m. and there we go and now it's listening again and wait ready hey Tim I already make a note what we wouldn't like me to write down remember this I might even go to net and there we go and now I can continue talking like I normally would as if we're doing the tutorial here and at any point if I say hey Tim I already make a note what would you like me to write down Tim I might even go hit that and there we go now I guess it didn't actually get what I said there but anyways you guys can see kind of how this works so it's always listening it waits for that wake word and yes it does take a second to detect the hey Tim I don't really know a way around doing that and changing that I'm gonna look at that and see if I can maybe fix that in the next video and give like some tweaks to how all this works but I think that's pretty good it's working pretty well now and I mean you get the idea right we're always listening waits for the wake word if you do it long enough pause between the wake word then it will say okay I'm ready or say whatever we have here it'll get the audio again and then it will actually do all of the commands so that is kind of how this works again all this code will be available in the text-based tutorial whenever that does come out of that being said as always if you have more ideas for the series leave a comment down below and I'll make sure to try to include that in future videos so with that being said if you guys enjoyed please leave a like and subscribe to the channel I will see you guys in more videos

Original Description

In this python voice assistant tutorial I will cover how we can create a wake keyword for our assistant. This word will allow us to trigger the assistant. Something like "hey tim". Text-Based Tutorial: https://techwithtim.net/tutorials/voice-assistant/wake-keyword/ Playlist: https://www.youtube.com/watch?v=-AzGZ_CHzJk&list=PLzMcBGfZo4-mBungzp4GO4fswxO8wTEFx ◾◾◾◾◾ 💻 Enroll in The Fundamentals of Programming w/ Python https://tech-with-tim.teachable.com/p... 📸 Instagram: https://www.instagram.com/tech_with_tim 🌎 Website https://techwithtim.net 📱 Twitter: https://twitter.com/TechWithTimm ⭐ Discord: https://discord.gg/pr2k55t 📝 LinkedIn: https://www.linkedin.com/in/tim-rusci... 📂 GitHub: https://github.com/techwithtim 🔊 Podcast: https://anchor.fm/tech-with-tim 💵 One-Time Donations: https://www.paypal.com/donate/?token=... 💰 Patreon: https://www.patreon.com/techwithtim ◾◾◾◾◾◾ ⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡ Tags: - Tech With Tim - Python Tutorials - Python voice assistant tutorial - Python voice assistant - Voice Assistant Python #Python
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Tech With Tim · Tech With Tim · 0 of 60

← Previous Next →
1 A* Path Finding Algorithm(Visualization)
A* Path Finding Algorithm(Visualization)
Tech With Tim
2 Python Programming Tutorial #1 - Variables and Data Types
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
3 Python Programming Tutorial #2 - Basic Operators and Input
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
4 Python Programming Tutorial #3 - Conditions
Python Programming Tutorial #3 - Conditions
Tech With Tim
5 Python Programming Tutorial #4 - IF/ELIF/ELSE
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
6 Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
7 Python Programming Tutorial #6 - For Loops
Python Programming Tutorial #6 - For Loops
Tech With Tim
8 Python Programming Tutorial #7 - While Loops
Python Programming Tutorial #7 - While Loops
Tech With Tim
9 Python Programming Tutorial #8 - Lists and Tuples
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
10 Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
11 Python Programming Tutorial #10 - String Methods
Python Programming Tutorial #10 - String Methods
Tech With Tim
12 How to Overclock a NVIDIA GPU
How to Overclock a NVIDIA GPU
Tech With Tim
13 Python Programming Tutorial #11 - Slice Operator
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
14 Python Programming Tutorial #12 - Functions
Python Programming Tutorial #12 - Functions
Tech With Tim
15 Python Programming Tutorial #13 - How to Read a Text File
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
16 Python Programming Tutorial #14 - Writing to a Text File
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
17 Python Programming Tutorial #15 - Using .count() and .find()
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
18 Python Programming Tutorial #16 - Introduction to Modular Programming
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
19 Python Programming Tutorial #17 - Optional Parameters
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
20 Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
21 Python Programming Tutorial #19 - Global vs Local Variables
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
22 Python Programming Tutorial #20 - Classes and Objects
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
23 Cool VBS Script to Prank Your Friends!
Cool VBS Script to Prank Your Friends!
Tech With Tim
24 How to Overclock an AMD GPU
How to Overclock an AMD GPU
Tech With Tim
25 Best GPU'S For Mining Ethereum (2018)
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
26 Recursion and Memoization Tutorial Python
Recursion and Memoization Tutorial Python
Tech With Tim
27 Ethereum Mining Rig - Hardware Guide
Ethereum Mining Rig - Hardware Guide
Tech With Tim
28 Pygame Tutorial #1 - Basic Movement and Key Presses
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
29 How to Install Pygame (Windows 8/10)
How to Install Pygame (Windows 8/10)
Tech With Tim
30 How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
31 How to Mine Ethereum 2018 - WORKING (Super-Easy)
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
32 Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
33 Pygame Tutorial #2 - Jumping and Boundaries
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
34 Pygame Tutorial #3 - Character Animation & Sprites
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
35 Pygame Tutorial #4 - Optimization & OOP
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
36 OBS Studio Tutorial - Best OBS Settings
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
37 Linear Search Algorithm - Python Example and Code
Linear Search Algorithm - Python Example and Code
Tech With Tim
38 Make Any Mic Sound AMAZING! (WITH OBS)
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
39 Binary Search Algorithm - Python Example & Code
Binary Search Algorithm - Python Example & Code
Tech With Tim
40 Pygame Tutorial #5 - Projectiles
Pygame Tutorial #5 - Projectiles
Tech With Tim
41 Pygame Game - Mini Golf
Pygame Game - Mini Golf
Tech With Tim
42 Pygame Tutorial - Projectile Motion (Part 1)
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
43 Pygame Tutorial - Projectile Motion (Part 2)
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
44 Pygame Tutorial #6 - Enemies
Pygame Tutorial #6 - Enemies
Tech With Tim
45 Pygame Tutorial #7 - Collision and Hit Boxes
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
46 Pygame Tutorial #8 - Scoring and Health Bars
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
47 Cloud Mining vs. Hardware Mining - 2018
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
48 How to Install Pygame on Mac OSX (Fast-Simple)
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
49 Pygame Tutorial #9 - Sound Effects, Music & More Collision
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
50 Pygame Tutorial #10 - Finishing Touches & Next Steps
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
51 How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
52 How to Create a Button in Pygame [CODE IN DESCRIPTION]
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
53 Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
54 Pygame Side-Scroller Tutorial #2 - Random Object Generation
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
55 Pygame Side-Scroller Tutorial #3 - Collision
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
56 Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
57 How to Create A Message Box in Python - Tkinter
How to Create A Message Box in Python - Tkinter
Tech With Tim
58 Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
59 How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
60 Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim

This video tutorial teaches viewers how to create a wake keyword for a Python voice assistant, allowing users to trigger the assistant with a specific word or phrase. The tutorial covers the use of Python, get_audio, and natural language processing to create a functional voice assistant. By following this tutorial, viewers can create their own voice assistant that responds to user input.

Key Takeaways
  1. Return said lower to avoid calling dealt lower every time
  2. Fix bug in get events function to include minute aspect
  3. Create variable for wake word
  4. Make while loop to always be listening for wake word
  5. Use a while loop to constantly listen for the wake word 'hey Tim'
  6. Check if the wake word is present in the text and respond accordingly
  7. Add a print statement to indicate when the assistant is listening
  8. Modify the speak function to respond with 'I didn't understand' instead of 'try again'
  9. Wait for a wake word and take a second to detect it
  10. Say 'okay I'm ready' if no wake word is detected after a pause
💡 The use of a wake word allows users to trigger a voice assistant and initiate a conversation, making the assistant more user-friendly and interactive.

Related AI Lessons

I Asked ChatGPT to Fix My Life. It Couldn’t — Until I Changed One Thing
Learn how to effectively use AI like ChatGPT to improve your life by changing your approach
Medium · AI
I Asked ChatGPT to Fix My Life. It Couldn’t — Until I Changed One Thing
Learn how to effectively use ChatGPT to solve personal problems by changing your approach
Medium · ChatGPT
Claude Sonnet 5 Is Here: Why It Might Replace Your Opus Subscription
Learn about Claude Sonnet 5, a new AI model that offers near-flagship performance at a lower price, and its potential to replace Opus subscriptions
Medium · Programming
Introducing Claude Sonnet 5 on AWS: Anthropic’s most capable Sonnet model
Learn about Claude Sonnet 5, Anthropic's most advanced Sonnet model, now available on AWS, and how it delivers top-tier intelligence for coding, agents, and professional tasks
AWS Machine Learning
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →