20,000+ Professional Language Experts Ready to Help. Expertise in a variety of Niches.
Unmatched expertise at affordable rates tailored for your needs. Our services empower you to boost your productivity.
GoTranscript is the chosen service for top media organizations, universities, and Fortune 50 companies.
Speed Up Research, 10% Discount
Ensure Compliance, Secure Confidentiality
Court-Ready Transcriptions
HIPAA-Compliant Accuracy
Boost your revenue
Streamline Your Team’s Communication
We're with you from start to finish, whether you're a first-time user or a long-time client.
Give Support a Call
+1 (831) 222-8398
Get quick answers and support.
Get a reply & call within 24 hours
Let's chat about how to work together
Direct line to our Head of Sales for bulk/API inquiries
Question about your orders with GoTranscript?
Ask any general questions about GoTranscript
Interested in working at GoTranscript?
Speaker 1: What is going on guys, welcome back in today's video, we're going to learn how to use speech recognition in Python. So let us get right into it. Alright, now in order to use speech recognition in Python, we need to install two libraries. And the first one has the creative name speech recognition. So we need to say pip three install speech recognition like that. And the second one is a little bit more cryptic. It is p y t t s x three, and I don't even know what that stands for. But this module, this p y t t s x three module is based on pi audio. And just a little warning here, pi audio is not always trivial to install. So sometimes you're going to have some errors pi audio can can be difficult to install. Let's put it that way. Now usually, all you need to do is or actually, it's automatically installed if you don't have any mistakes by just installing this library. But usually you just say pip install and then pi audio or pip three install pi audio. On Linux, you sometimes have to do pseudo apt, at least on on Debian based version, pseudo apt install, and then Python three, dash pi audio. And sometimes you're going to have some errors on Windows or on Linux, then you might have to install the wheel files manually, or to use the dash dash user tech and so on. However, I think this falls into the category of googling. So watch the one video that I that I uploaded a couple of weeks or days ago, which is the art of googling as a programmer or googling as a superpower. I can't remember the exact title. There you can learn how to google properly. And you just if you encounter some mistakes while installing these libraries, just google and you're going to find your way to the solution. So then we're just going to create a new Python file. And here we're going to import first of all speech recognition, but we're going to use an underscore here because even though we install speech recognition without any blanks or underscores, we're going to have to import speech underscore recognition. And then we're going to also import pytt sx three. So those are the two libraries that we're going to import here. And then we're going to build a recognizer. So this is going to be our object, we're going to say recognizer equals, and this is part of speech recognition. So speech recognition dot recognizer, with a capital R. And this is just going to be our object that is going to, to make sure that it understands what we're saying into the microphone, then we're going to have an endless loop. So while true, and then we're going to try something. And if this doesn't work, we're going to have an except block here. And some error handling or just skipping the current iteration here. And now what we're going to do here is we're going to say with speech recognition, dot microphone, so we're going to use a microphone as an input here. With that as Mike, we're going to say recognizer dot adjust for ambient noise. The source of this is the microphone and duration, we're going to set this to 0.2. So that it recognizes when we start talking and stop talking. And then we're just going to say audio equals recognizer dot listen, going to listen to the microphone here. And then we're just going to extract the text. So we're going to say text equals. And then we're going to say recognizer dot recognize. And here we can use the source. So we can use Bing, we can use IBM, and so on. We can use Google, which is what we're going to use here. So you just have to pick the source, and the language and all that. So here, you can see in the documentation that you can pick a language and set some other parameters like grammar, and so on. But we're just going to go for Google. And we're going to leave it at the default language, which is English. And then we're going to have to pass the audio data to this function. So we're going to see recognizer dot recognize Google. And here we're going to pass the audio source or the audio itself. And then we're just going to say text equals text dot lower so that we don't have any cases that we don't like. And we're going to print the text. So we're going to say recognized. And the text here, we need to make this an F string. Otherwise, this is not going to work. And this is actually it. Now what happens if we get some value error, because this happens from time to time. So if we get a speech recognition dot unknown value error, I don't know exactly when this happens. But if it happens, it's mostly, you know, it's not a big deal, we can just skip the whole thing and start start from scratch. So we're just going to basically copy this initialization here. We're going to dentists, and then we're just going to continue. So basically, what we're doing is if we get some error, and we don't know how to proceed, we're just going to set up the whole thing again. And we're going to skip this iteration, we're going to start all over until we get this same error again. So this is a very basic speech recognition script. So now we have the script on a desktop, and we're going to give it a try by running CMD and navigating to the desktop. So CD desktop, and then just Python main dot p y. Now, as I'm talking here, it's going to recognize what I'm saying. So let's just wait for for the result. As you can see here recognized now as I'm talking here, it's going to recognize what I'm saying. So let's just wait for for the result. So even if I'm making a mistake while talking, it's going to recognize that and now we should get a pretty long sentence. Yeah, as you can see now, it's not, it's not perfect. I don't know if it makes any mistakes here. But I'm certainly making mistakes while I'm talking. So we're going to see some interesting results when I stopped talking here. Yeah, there you go. So this is basically the speech recognition script. And you can use this, of course, to make a voice assistant, for example. Now I have a video on this channel about an intelligent chatbot about a virtual assistant. And you can combine this with this speech recognition and make it a voice assistant. And maybe I'm going to make a video on that in the future. So let me know in the comment section down below if you want to see such a project. And you can combine this with all sorts of things you can automate your home if you have some access to your light bulbs, for example, or to a smart fridge or a smart toaster. For example, you can just say something to the script and then the script recognizes Okay, this guy wants me to start the coffee machine, for example, and this can be done with this script. So that's it for today's video. I hope you enjoyed and hope you learned something. If so, let me know by hitting the like button and leaving a comment in the comment section down below. And of course, don't forget to subscribe to this channel and hit the notification bell to not miss a single future video for free. Other than that, thank you very much for watching. See you in the next video and bye.
Generate a brief summary highlighting the main points of the transcript.
GenerateGenerate a concise and relevant title for the transcript based on the main themes and content discussed.
GenerateIdentify and highlight the key words or phrases most relevant to the content of the transcript.
GenerateAnalyze the emotional tone of the transcript to determine whether the sentiment is positive, negative, or neutral.
GenerateCreate interactive quizzes based on the content of the transcript to test comprehension or engage users.
GenerateWe’re Ready to Help
Call or Book a Meeting Now