Technology

Build A Voice Activated ChatGPT on Your Phone


Today we’ll be building a custom chat GPT chatbot that works on your iPhone and not just that it will take voice input as we will be integrating The Whisper API and as per usual no matter your technical level this tutorial is going to make the custom chatbot right

On your phone accessible to everyone so here’s the plan for today we’ll be building free versions of this alright the first one is an extremely simple version literally everybody can copy paste this and make this happen because we’ll be using telegram which makes it very simple to integrate this bot

Secondly we’ll make a slightly more complicated version also in telegram which remembers your last messages this is where it starts getting interesting and the third one is the most interesting part of the video here because it’s going to be able to accept your voice messages that’s right you can

Pick up your phone record voice messages and you’re gonna get a reply from Chachi BT impossible and not just basic chat chipity you’re going to be able to set it up so it has a personality that you pick in advance and all of this can literally be done with no coding

Experience whatsoever but I would say this if you’re completely new and never touch code before I recommend you check out my last video where I taught you how to install the app that allows you to run the code and there I really start from the ground up and show you how to

Use the chat GPT API as a beginner because today we’ll be building up on our tutorials keeping the two basic steps of installing vs code and getting your open AI API key which is still incredibly easy so everybody should be able to get that done alright it’s time

To get into it we’ll start on the phone so for all the free scripts you’ll need the telegram app so download that first once you’ve got your account set up you simply go to the search and look for botfather alright now you open a new chat with this verified account and I

Did this before and in here it couldn’t be any simpler all you do is type Slash new bot and then the botfather is going to ask you all right a new bot how are we going to call it please choose a name for your Bot so I’m going to say AI

Advantage nine thousand and one good now let’s choose a username for your Bot it must end in bot like this for example tetrispot or tetrispot so we’ll say a i Advantage 9001 but perfect and it replies with our API key all you need to do is copy this message and bring it

Over to your laptop because this is one of the two things we need to make it work we need the telegram API key and we need to open AI API key all right and also what you’ll need here is the python script that I’m providing to you in the

Description below there’s a Dropbox link which makes this really intuitive for anybody who hasn’t dealt with code before but I also put this in my GitHub repo for you more advanced users all you gotta do is download this folder and then all you need to do is take that

Folder and drag it onto Visual Studio code click yes on this and then you’ll want to open the very first script zero one dummy chatbot so this one is named dummy because it only takes one command and it doesn’t remember but it’s a perfect starting point to explain this

So let’s get into it okay so here’s the message from my iPhone and all I need to do is copy this API key over here just like that and then inside of the script all you need to do is go to telegram API token and inside of the quotation marks

You post your telegram API key makes sense now the next step here is copy pasting your open AI API key we went over this in the last video but just as a reminder under this URL you can always create a new API key and yet again we

Copy paste it into the quotation marks right after it says open AI API key okay before we go any further I want to give you a quick and super simple explanation on what’s going on in this code okay so we just talked about the two API keys

This is just a way to link to the app so the telegram API token allows you to link directly into the chat inside your telegram app on your phone and the open AI API key allows you to interact with chatgpt above here as you might already know these are the different packages

That we’re going to be using as a beginner you can also think about these as presets that make your life really simple in here so obviously with the open AI package to make chat GPT work and then also with the telegram package which makes it really simple to connect

To custom chats within your phone okay down here we have a function and this is just the basic way of interfacing with a chat inside of your phone if you want more details on all of this you can always find them in the telegram API documentation but all you need to know

Is that this function allows you to send messages inside of telegram and this part is the chat GPT integration as I showed you in the last video we’re using the GPT 3.5 turbo model here because it’s the cheapest and it’s still excellent right after content you get to

Define the personality of your Bot so here we’re saying say that you’re a dummy chatbot and add a silly phrase okay and this part down here you don’t really need to understand it’s just how the telegram package functions roughly speaking every few seconds it starts polling and looking for new messages and

If it gets those it starts interacting and you get the results you want which is a text message communication with the chat GPT API here alright so we’re almost ready to go here all we need to do is go to terminal new terminal and now you might have noticed that there’s

This four file in here requirements and this file is here just to make it super simple to install all the packages and again you don’t need to understand what’s going on inside of the terminal here all you need to do is type pip install Dash R requirements.txt if

You’re on a Mac it might be pip free and install both of those will be in the description below and then when you hit enter it automatically installs all the packages including Telegram and open Ai and let’s just switch up this part so it says you’re a helpful assistant that always

Responds with a joke now we Define the personality of chat GPT and we’re ready to run this script so just go up here press play and now the script is running on your computer just remember that if you close this it’s not going to work anymore because it’s running from here

That’s it our chatbot is running on this machine right now so now if I open up my phone so inside of the newest message with the botfather it links to our new bot so just click the link at the top here and at the bottom you can start the

Chat with the brand new chatbot let’s just say write me an essay about Borat why did the tomato turn red because it saw the salad dressing okay one of the standard chat GPT jokes and it does that because we said you’re a helpful assistant that always responds with a

Joke so we forced it to respond with a joke so you can set this up in any way just remember that this doesn’t remember your previous messages this is just the most basic setup but it works okay and as we’re developing custom apps today you might need a hosting provider to

Host your ideas once they’re done that’s why today I partnered with a website you should know about hostinger they make website hosting easy and provide everything you need to create a stunning website with hostinger you’ll get a free domain with the shared and Cloud hosting plans 24 7 customer support and a 30-day

Money-back guarantee they’re highly rated on trustpilot Google and WordPress beginner so you know you’re in good hands you can choose from shared cloud and VPS hosting plans the latest ones are the ones that can support your apps and help you launch them online with their VPS you can get full root access a

Dedicated IP address and much more all that you need to successfully host your application the VPS plans start for its lowest 3.99 a month and with my discount code AI Advantage you’ll get an additional 10 discount for VPS and all other plans so don’t forget to use it

The VPS comes with an easy setup where you can select your preferred server location operating system and even control panel and if you’re looking for something even easier check out their shared hosting plans they’re optimized for WordPress and come with a one-click WordPress installer together with Lightspeed web server technology and

Advanced case Solutions you can always choose from their website builder that comes with designer made templates and requires no programming knowledge to create a website and with 24 7 support from their team you’ll never feel lost over 1.5 million website owners trust hostinger and with their 30-day money-back guarantee you can try them

Out risk-free so if you’re looking to start or improve your online presence if hosting a try click the link in the description below to get started and now let’s get back to today’s video so let’s move to the second script here zero two simple chat bot does the same thing as

Previously but now you’ll get to interact with it on an ongoing basis again you need to update the API keys in here first for this to work you can just copy paste them from the first script and as you can see this code is a little longer here and that’s because we have

This reply functionality in here other than that again you don’t really need to understand this and we already installed all the packages so again all we need to do here is press play and the script is gonna start running on our local machine here because we use the telegram API key

That links to this chat we can go back in here and do another request let’s just do the same right when I say about Borat Aha and here I noticed another joke so this means our first script is still running so you have two options honestly

The simplest one is if you just close vs code completely and reopen it but you could also go in here and inside the terminal you press Ctrl C on a Mac enter and that’s gonna make it stop but just remember you can always just close the

App reopen it press play on the second script and we’re back in the game again right we’re gonna save up board I really want that essay wait a few seconds this is natural chat GPT takes a little bit of time and there it goes isn’t this just

Perfect look at that the message always starts with bot because that’s what we hard coded in here if you look down here you’re gonna see the Bold formatting and the bot text if you want to remove or alter that you can simply take this part out and we’re gonna remove that but the

Message starts with bot here by default and then the chat GPT responds Borat is a fictional character created and Portrait by the comedian Baron Cohen yada yada yada and then we get the rest of the essay so again it worked and then if I follow up here with why is he so

Popular question mark as the script also remembers the chat history you’re gonna see that this answer is contextual and it talks about Borat has gained a massive following and become an iconic character because of his unique comedic style AKA it remembers that we meant Borat without mentioning it in the last

Message this is getting pretty cool right but the next script is really what this is all about because if you want to show chat GPT on the phone to some people one of the coolest things you can do trust me on this is make this third script work and it’s really not that

Hard it looks a little more complicated but again you can just copy paste all of this and learn it later I do want to say one extra thing about understanding this code here because I feel like it’s important and that is you can always take this function copy it into gpd4 and

Ask what does this do and it’s going to tell you and you always have the ability to follow up with more questions and that’s how you learn but for me personally my favorite way is just making things work somehow getting excited from the results and then

Learning how all the details work so you can do the same here just open up the third script and again we’re gonna need our open AI API key up here the telegram API key oh and of course if we go into the terminal again we’ll have to press Ctrl C to stop

The last script from running because otherwise the second script bot would still be active on our phone and here we have super telegram GPT a helpful telegram bot who is also extremely funny and very confident and you like to throw people a bit alright so just like before

This function allows us to send messages to Telegram and gets us the chat GPT response what is completely new though is this following function so this is what you need to send voice messages to the telegram API and it’s not just that within here hides one thing that I need

You to be aware of and that is the so-called whisper API whoa a new thing what is that very simple openai offers multiple apis one of them is the chat GPT API and besides the older GPT free API and the newer gpt4 API they also have a completely different product

Called whisper which is all about speech to text that means it takes the words from us sound file and it turns them into a transcript and then it takes the transcript and sends it to Chachi BT because chat GPT doesn’t take voice it only takes text right so again we allow

The telegram chatbot to accept your voice then we transform the voice into text and then we send that text to chatgpt and get a text reply and that is it kind of I left out one thing which is not essential to understand but I want to mention it anyway and that is when

You record voice messages inside of telegram they come in this dot OGG format which is just an alternative to MP3 and Whisper wants MP3s which you’re probably familiar with and that’s right here at the top we had to import the movie Pi package which allows us to

Transform the OGG to MP3 so really it’s your voice to the telegram voice function which turns it into OGG then we transform that into MP3 that MP3 file of your voice message goes to the whisper API which turns it into text and then we send the text to the chat GPT API which

Returns a text response okay I hope that makes sense and if you want to go even deeper again open up the telegram documentation or ideally use gpt4 to dissect this line by line and use the prompt explain this code step by step to a beginner alright enough talk let’s do

This let’s press play on the script and let’s see if this works write me an essay about Borat and here it’s set up to give you a message that lets you know that it received the voice message I also included the line that shows you exactly what the voice message got translated to

For whisper in this case it’s perfect write me an essay about Borat and there you go or at Saga DF Portrait by Sasha Baron Cohen is a fictional character that has taken the World by storm perfect we made it work how could I be more like Borat and again it says I’ve

Received a voice message please give me a second to respond how could I be more like Borat and the cool thing is that if you look at your computer in this terminal you’ll see all the actions that are happening so second ago movie pie was writing audio invoice message dot

MP3 and also as you’ll see in the folder here above it saves the different voice messages that you sent to this bot and there you go a bunch of recommendations on how could I be more like Borat while borat’s Antics might be entertaining to watch it’s important to remember that

His behavior Can often be inappropriate and offensive yeah fair enough but that’s why he’s funny anyway so that works isn’t that incredible but given I have to keep my computer open or run this on my desktop at home which is my usual workflow but now the obvious

Question presents itself how do you go further than this how can you make this run 24 7 so this telegram bot is operational all the time independently of you running vs code on your computer at home well but I fear that goes beyond the scope of this tutorial you will need

To host this python script on a service like AWS which is just not beginner friendly enough for me to include it in this video but I’ll include a link in the description below to another tutorial that explains this really well but hey if you want me to create a

Tutorial like that just leave a comment below I can do that too and with that I think we got episode 2 out of three in this mini series that shows you how to work with the chat GPT API I’m currently thinking of making a third episode and

The idea there is showing you how to get text to speech back from the bot so you speak turbot and it speaks back if that’s something you’re interested in leave a comment below otherwise share your ideas what other tutorials you would like to see and otherwise I hope

You have a lot of fun with this little telegram custom bot and all I would say is show it to your friends show it to your family this is something that 99 of chat chip users will never achieve so go ahead and use it to your advantage and

Check out the next video I’ll see you there

#Build #Voice #Activated #ChatGPT #Phone
For More Interesting Article Visit : https://mycyberbase.com/

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *