a way to make a Discord Bot in Python! (Part 4: playing Audio Files)(2021)<br/>hello neighbors it's james and welcome and. welcome back to my channel. so this is facet 4 in making a. discord bot. in python if you haven't watched the. last 3. episodes i'll depart a link for those in. the outline. i'd enormously advise you watch those. before you watch this video. as this video follows immediately on from. them. so in the last episode we covered. joining and. leaving voice channels so we obtained our bot. to. become a member of our voice channel when we typed in. a command and we additionally obtained our bots. to depart a voice channel on command so. then. in this video what we're going to be. doing is we will be getting our. bots to play a. sound when it's inside a voice. channel. i know in the last episode i stated. that in this video we would be going over. that aas well as. getting our bots to play sounds from. youtube videos from youtube.<br/>I'm actually going to be saving that to. the subsequent video. so in the subsequent video i'll be. displaying you ways to get your bot to play. movies from youtube. notwithstanding if you're just seeking to get. your bot to play movies from youtube. and that you just don't want it to play. sound files i nonetheless propose following. alongside during this video. because this video will still cover plenty. of the basics that you would need. to get your bot to play video clips from. youtube anyway let's simply get started. let's jump directly in. so then first thing we have to do is. install a few applications. and these applications will sincerely. permit our bots to read the sound. documents to read the song after which to be. ready to play it. so if you are following alongside in your. computing device on your home windows laptop. then i'm going to assist you to do it. now. however if you followed the video where.<br/>I confirmed you the way to set it up in your. raspberry pi. i will be leaving a timestamp on. the display screen right here. wherein i will pass over how to put in those. programs at the raspberry pi. as it's a bit distinctive to home windows. anyway i'll go over the home windows bit now. and then the raspberry pi bit. after which the code so then let's get. began in a windows bit. so then let's set up it on home windows so. the first thing you need to do is open. up your browser. once opened you must go to an internet site. known as. ffmpeg i will leave a hyperlink for this within the . description. then you definitely desire to come over to the facet. and click download. and then you must scroll down and. click on home windows. after which you need to cross down and click on. on home windows construct by. btbn after which click on it and it will take. you to a github page. and then so you want to scroll down and.<br/>You must click on. on this one right here click on it and it will. set up as you will see down right here and. just to expose. to you that it's not an outbreak i'll run. a safety determine on it. as you will see that here is just run a. security assess on it. and it's found not anything no damaging. viruses or files so it's flawlessly. secure to install it so once it's. installed you must cross forward and. click extract you need to extract what is. inside of here so extract. and then you must select a area. i'm just going to extract it to my. downloads after which you want to click. extract provide it a second and it will. extract and. there we move it has now extracted okay. so it's extracted and if we pass into the. extracted folder. you will find here we've got this and if. we go into the bin folder we've got. 3 executtable binary documents and this. is.<br/><iframe src="" width="560" height="315" frameborder="0" allowfullscreen></iframe><br/>Ffmpeg so you must replica it so. correct click on and click reproduction or handle c. on the keyboard there we go. and now we need to paste those files in. a vicinity. these are where those documents are going to. survive our laptop. so most people when using ffmpeg. store it in the c drive um right here the. nominees to create a folder right here and. simply name it ffmpeg. or program documents or anything around. these lines actually don't create it. referred to as program files because one already. exists. but it's cool create one called ffmpeg. and paste it in here. notwithstanding i'm not actually going to do. this i'm going to store it on my different. hard disk. my work drive right here notwithstanding you do not. need to do this you could shop it on the. c. force right here so create a folder name it. ffmpeg. and then inside of here paste these. documents. but as i simply stated i'm not gonna be.<br/>Doing that but i am gonna go ahead and. paste it in my work dossier. so there we move i have pasted it inside. a folder that i have. on my work force notwithstanding as i reported. previously distinct times you may just. do it on your c. force it isn't important so now we are able to. cut back this because we do not. want it so what we now must do is upload. ffmpeg to our course so what the path is. is it in actual fact. enables specific purposes to have the ability. to entry it to be. to allow it to be accessed from anywhere. on the pc. if that makes sense don't worry in case you. do not comprehend it i'll enable you to. set it up. so what you need to do is come right down to. the windows seek and type direction. once you've typed direction into the home windows. seek bar. you will have two options you want to. come down and click on the one that says. edit the manner environment variables.<br/>A field like this will open you want to. come down and click on. environment variables the an extra box. like this would. open you must come right down to the manner. variables section. you want to scroll down until you spot. course and you want to double click on it. it's now going to open up this long list. you may not have many or you've gotten. menu. it doesn't actually matter so what you. have to do is come upon and click on. new and now we need to paste the. region of where you installed. ffmpeg in which you copied these files to. so if we. open again up that window that we simply. minimized where where we copied in. those documents. we want to reproduction the location in an effort to do. thiis if we click on up here. uh it is going to move like this and you simply. click on copy it with the aid of doing ctrl. c is now copied so now if we get back. to right here if we click on. new after which we can paste it you'll discover.<br/>Here look. it is now looked and now we simply need . to click on enter and there we cross. now we have added it to our path so we. desire to click on ok. and only a reminder back uh be sure. it really is the situation of in which you. mounted in which you copied these files. to. so you want to click ok and now we will. simply click. ok and close it now we will close this by means of. just clicking okay. there we go we've now successfully. set up ffmpeg. so we now need to ascertain that we've. set up it adequately so to try this on. your keyboard hit the windows key plus. ah after which come over here after which you. want to type. cmd after which click ok there we cross so the. cmd has now opened. so to test if it has worked competently you. desire to sort ffmpeg. edition and then input and there you move. it has worked. ffmpeg has effectively set up. notwithstanding sprint dash edition does not look.<br/>To work um. yet that doesn't topic because besides. we know that ffmpeg is installed. so if you get whatever that says ffmpeg. version like this at the top you know. you have correctly installed. ffmpeg so now i will show you. how to install it if you're running your. bot. in your raspberry pi so if you have been simply. following alongside the windows area. i'll leave a timestamp on the display screen. right here to the portion of the video that. you may bounce. to uh wherein i'll move in the course of the code of. getting your bots to play. a valid file so now directly to setting up. ffmpeg onto your raspberry pi. so i am now on my raspberry pi so let's. set up. ffmpeg so to do that we wish to open up. the terminal. there we go and now we wish to kind this. we wish to sort sudo apt. install ffmpeg. after which click on input supply it a second. and iit's going to cross forward and iinstall.<br/><a href="">welcomer bot discord</a> . so it's now interestingly efficiently. mounted so let's. test to work out whether it is mounted to be able to do. this we sort ffmpeg. sprint version provide it a second. and look there we cross it has worked if it. pops up with saying ffmpeg. edition after you've typed this there. you move you have correctly installed. ffmpeg on your raspberry pi so now. let's jump into the code let's get our. bot. to play a few sound okay so we are now. returned within the code. so let's get our bot to play a legitimate. file. so first thing we do earlier than we start. coding is that you actually need to. restart your laptop or computer or whatever. device your raspberry pi you must. restart it. it is just to ensure that ffmpeg. has taken full. effect and that your technique can. realise it. although that we checked it and was. hooked up via the cmd. and via the terminal at the raspberry pi.<br/>We still just must restart it. simply in case due to the fact you'll be able to get. errors if you haven't restarted. so you have now restarted which is good. let's begin writing so the very first thing. in our code that we have to write. is we have to install a package at the. appropriate. we need to install the ffmpeg pcm. audio this line here i have already. written it in. pause the video right here so you may copy it. and paste it into the top area. right here so we now ought to scroll back down. and. inside of our become a member of our become a member of function. it's where we're going to be writing. our code. at present so the very first thing that we are. going to do is we're going to assign. a variable to this watch for statement so. what we will do. is before this awaits we'll. kind voice is the same as. after which the await section here simply. like this. and then lower than here we'll variety.<br/>source. is the same as ffmpeg. pcm audio and it truly is what we have. mounted. up here ensure it's an analogous you can. try this by a dead ringer for copying it and. coming down right here. and pasting it just to ensure that it. is the same and after this part right here. we want to do brackets. and iinside of those brackets that's. where we will be. telling our discord bot um ffmpeg. um what our file name that we wish to. play. is so it's the point wherein you. really want. to get an audio file to play so i. have already got. i have imported a only a ordinary piano element. that i found on line a hassle-free piano. audio file that i found online it's. totally loose to use. and um i have just imported it into my. directory where my bot is. ensure you additionally import the audio dossier. that you're going to discover into a similar. listing that you have your python.<br/>Dossier in. so once you've discovered an audio dossier that. you need to use. you must input the name of it. inside these brackets so in my case. it's referred to as piano dot. wav is just a audio file extension. so i'm going to write this in right here piano. dot wav. so we've now informed our discord bot what. the name of our file is. so now we really need to tell it to. play it so what we'll do is. come down right here and we will write. a brand new line. we're going to say player is equal to. voice dot play open and close brackets. source and there we go that should be. every thing. our bot should now work it may now. play. an audio dossier the audio dossier that we. gave it so in my case the piano or. you're giving your bot to play. so let's try it out let's come down. right here to our terminal and run our bot. like we have completed.<br/>Ago in the previous series so we. can kind python3. leading dot py and then input here we move. provide it a second for it to load there. you go our bot is now all set to be used so. let's head to discord. okay so i am now within discord so let's. join a voice channel. ensure i'm muted which i am so. there isn't any weird feedback and now let's. get our bot. to hitch and optimistically optimistically it. should play. the audio dossier that we gave it so in my. case the piano. or whatever your audio dossier comprises so. let's provide it a go. it works convinced our bot is now. our bot is now playing our audio file it. now works. that's so cool so we've now been capable. to get. our bot to play an audio dossier. ok so that now brings us to the tip of. this video. in the next video we're going to be. getting our bots. to play audio from a youtube video. which is going to be surely cool so stay.<br/>

This user hasn't created any releases yet. Find more releases from other users: