Create a ChatGPT & Bing Powered Voice Assistant with Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
how do I add other features it works but it's not optimal it says error you exceed your current quote I would definitely use open AI whisper for transcribing you didn't use new gbt 3.5 turbo you really need to make this interact with Bing chat the last chat GPT Voice Assistant was handy but check out this new one okay Bing what can I help you with when was mid-journey V5 released to the public mid-journey V5 was released on March 15 2023 is there anything else you would like to know about it GPT what can I help you with write a diss song about how my new Python program is superior to my old Python program it's got the power of my old programs outdated it's a coward whoa calm down tomorrow don't pull out the knot I got a ton of great ideas to improve upon our voice assistant my favorite idea was to add ability to prompt bing bing AI unlike any of the open AI apis has access to current data by searching the web for information that chat GPT is not trained on well here's the problem being a AI does not have a publicly accessible API for us to use in Python programs I have to say that you're fine when you're not really fine but you just can't get into it because they would never understand this means unless we or someone else creates an API for Bing we are confined to that piece of interface we all know and hate so I went to where every developer should look for free open sourced programming tools GitHub GitHub has this project by a bunch of amazing python developers that is an open source reverse engineered Bing API now that I know it is possible how do we get started first start by installing python onto your computer if you have not already we will want version 3.10 since openai whisper still doesn't support python 3.11 we then need to get beta access to Bing AI once we can use Bing AI as intended through the browser on our computer we just need to install the GitHub project from earlier let's do that by typing this pip command into our computers terminal pip is a package managing software for python that allows us to quickly install python libraries now let's get Edge GPT setup as explained in their GitHub readme document as you can see C we need to install a browser extension called cookie editor it says Chrome or Firefox but I can only access Bing through Edge so I will get the extension for Edge I will use the export button to copy the cookies file within my code editor which is vs code today I have an empty folder where I will create the cookies.json file and paste the file we copied from our browser and save this file now it looks like I'm ready to create a python file to begin testing this Edge GPT API I will call it main.pi now I can follow the developer demo instructions it looks like we will need to load the Json file we created so I will copy the reference code below and then specify the Cookie's file path as they described after that I will hit save and let's test it out as you can see it prints out an entire python dictionary variable with a bunch of data we don't need for a voice assistant so I remove the print statement and added this code block from Line 6 to 11. the program will now take our prompt input in terminal then print the cleaned up response from Bing now we have the response but it has these bracketed numbers that serve as links when using the Bing website this will just have our program reading random numbers that aren't relevant for voice interaction so I imported the re AKA rejects library then using this line of code we can remove The Unwanted links in our text response great now we have the Bing AI API functioning perfectly for our application let's make the program run on a loop so that it keeps answering our question until we quit the program manually in Python this can be done by wrapping the code in a while true Loop it will return a clean text response from The Edge GPT API now next I want to make the program take voice input with a wake word I will be using open AI whisper locally for transcribing audio to text to do so I need to install whisper on my machine then I will upgrade whisper to the latest version finally I will install ffmpeg using the Brew command as specified for my operating system I will also be using the speech recognition library for recording microphone input since whisper does not have that feature built in so let's install that I need to import the whisper and speech recognition libraries then set up the recognizer object and create a wake word variable so that it is easy for you guys to change to a wake word of your choice later next I will write this function on lines 11 to 15 that will be able to check if a voice input contains our wake word I then wrote this block of code inside our main function on line 20 through 41 to start our program recording from the microphone transcribe the voice input with whisper and check if a wake word was spoken if the Wake word was spoken the Python program will continue alright so this is what the program should look like so far if you have been following along at this point we need our program to have Text-to-Speech capability so that it is 100 voice Interactive instead of using pi TTS X3 for local text-to-speech like the last tutorial I want to use an API that gives us a way higher quality voice from our program I will be using AWS polynural engine to create a realistic text to speech voice to do so I need to install and import the bot-03 library for accessing AWS Services as well as the pi dub library for playing the MP3 file that AWS will send us let's write a function to create our text to speech using poly I will be using the voice called Sally there are many voices available from AWS poly by setting up a free AWS account I can play with poly in the browser to find the voice that works best for me they even have a ton of language specific voices for non-english application make sure you select the neural voices as that is what will give us the best quality voice and the engine specified in the code too let's import the boto3 and Pi dub Library I also need to import playback from PI dub I now need a short function for playing the speech file with pi dub now I just need to call on these two functions to make our program speak our responses with a realistic text to speech voice I will do so on line 63 and 64 for our program to verbally request our prompt after it has successfully heard our wake word then again on 97 and 98 to speak our response from Bing AI that was a lot of code Let's test it to make sure I got it all working okay Bing what can I help you with how cheap can I fly from Los Angeles to New York next week sure I can help you find some cheap flights from Los Angeles to New York next week according to my search results the cheapest one-way flight is 59 perfect I now have a python Voice Assistant that can access Bing and give me intelligent answers to recent events and news Well you may have noticed I prompted the chat GPT API in the intro as well I want to be able to use Bing for questions that need to search the internet to be answered and when I want a faster response with the better creativity from chat GPT I can prompt the chat GPT API since I already have a fully functioning Voice Assistant all I need to do is set up a second wake word so the program knows which API I want to prompt let's write these lines in the get wake word function we made earlier to do that then I can install and import open AI now I will initialize the API by passing in my API key to get a free API key with a free allowance of prompts from openai sign up and create one on openai's website then copy your API key and paste it inside the quotes once we have done that we will write this else statement containing a code block to connect to the GPT 3.5 API and get a response to our voice prompt now we have a complete Voice Assistant that can prompt Bing when we say Bing and chat GPT when we say GPT if you want to compare your code I have included a link in the description to a GitHub repo I will see you in the next video
Info
Channel: Ai Austin
Views: 46,422
Rating: undefined out of 5
Keywords: OpenAI, ChatGPT, Bing AI, Python Tutorial, Voice Assistant, AI Assistant, ChatGPT voice, chatGPT voice assistant, Ai voice assistant, Programming, Artificial intelligence, AGI, Tech with tim
Id: aokn48vB0kc
Channel Id: undefined
Length: 7min 57sec (477 seconds)
Published: Sun Mar 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.