Speaker 1: Hello friends, welcome to my channel JCBA Coder, well I want to thank all the people who are subscribing to the channel, we continue to grow and well, to the point, in this video tutorial we are going to learn through Python already a little more advanced, we are going to work classes, functions and interesting things, we are going to learn how to transcribe an audio that is recorded in real time with the microphone of the computer, then the first thing they should do is install this library we are going to install that library install speech recognition ready we hope that it is installed once installed we install the other spy audio ready the next step is to start to code we are going to do a class, we are going to write a class and I'm going to call it transcribe perfect in this class we are also going to initialize the parameters that come by default then we put the same we are going to put here the format of the audio that we are going to record that is going to be of type by audio, that is, the library that is at the top, well, we forgot that above we must import the libraries, import speech recognition, also import by audio and finally we are going to import another very important library that is wave and this one up here we are going to import it as the sr connection as it will be ready then we are going to work for it a little more advanced to each of the parameters that we are going to receive we are going to put a type then this is going to be of type for audio it is going to be the format of the audio we are also going to receive the amount of channels that that audio is going to receive that we are going to record is going to be whole type something else that we also need the sample cup, sample cup, which therefore will also be whole, also something more we are going to use is the size of the buffer, we put the buffer size and this will also be whole, what else do we need, the duration of the recording, we have to is going to be a duration to the graduation that we are going to do duration graduation and this is also going to be a whole and finally the route of the file that we are going to save when we record it we put the file route etc. of type string and at the end we put two points we give an enter and write here for now I am going to create a peace here to format up ready now I'm going to start here we are going to define the default values so that when we load them the other functions can have data then be the point format will be equal to self.channel format will be equal to the channels self. sample rate will be equal to the sample rate and so on self. buffer size will be equal to the buffer size self. duration recording will be the duration recording and finally the file root point will be the same the root file is perfect once we have this we can continue with the other functions we are going to create another function I am going to call it record well I am going to put audio recording this will allow us to give the audio as we are working with a class it is necessary to put here the word self is worth then here we start with the logic of what is the recording of the audio then for that case what are we going to do we are going to as always I have told you in the other videos we are going to work with the trash with the strikes except ready then here I here I already have a little advanced that part to advance a little in the video of the strikes except then we put this as we are good here it would be an error when recording the audio record the audio says comma check and show us the error a error occurred when recording the perfect audio once we have done that we go here to define a variable and we put here for audio point audio here we are already defining the audio object to be able to start doing the streaming audio as such the recording that we put a variable that is called stream and we are going to equalize it to audio, that is, the variable that is at the top and we are going to put audio point open that allows us to open the microphone and start recording and that receives this receives a format the channels the sample rate the input if it is from input or output and the amount of audios that is the size of the buffer then let's start to pass the parameters that we define above we put you here format will be the same as the point format what else the other that I told you the channels 3 channel equal to make channel points receives another parameter then here would be the ratio or the sample rate, we put rate and here we put sample rate, perfect, we are going well, we put a comma and we pass another parameter that if it is input or output, we put input and we put it as true, comma and finally it receives the amount of buffer, the size of the buffer, before it is called frames per buffer itself there is the point size size buffer perfect ready then the next thing we are going to do here is I am going to put a print that tells me start recording start recording something like that we put that so that it seems that it is running ready now we are going to define a list I am going to call frames and we are going to put something here I am going to put recording of the audio then here we are going to put for and in range and here it will go from 0 to and a formula that we are going to put here the data are whole then we put here sample rate we are going to divide it by the size of the buffer and we are going to multiply it by the duration of the recording so that you can open the program until when it will go and when it will stop then we put here self point sample rate divided by self point buffer size and we are going to multiply it by the duration of the recording perfect ready now we have finished this little part here we go here inside and we put here a variable of any where we are going to save the data that we are recording it is going to put here data and I put stream.read so that it does not read us and we pass the size of the buffer size perfect buffer and after that we are going to the frames we are going to add the frame that we are recording so that it is saving it in the list we put frames point to ping and we pass data ready after this below we are going to put a print here and we are going to put finished recording finished recording finalized perfect ready then what would happen to be we are going to write here stop the recording stream and close audio file because we have to close it so that it does not consume so much space in memory ready then here we put swing that was the variable that we defined above point, stop, stop stream, we open and close parentheses and we also put stream point, we put close and finally the audio that we define the audio variable that is here above, this one, we are going to do the following audio point and finish this so that the process ready ok perfect then the next thing we are going to do here too once we finish this is to save the recording that we did I'm going to put here save the recording and we do the following let's go to define a variable of any I'm going to put wf and I'm going to put here wave remember the library that we import the third library we have wave.open that we pass and we are going to pass the route to save point route file and wv that is so that you can write and save ready then what else would it be wf point pass the channel where we are going to record here it is that it will be equal to the channel, then we put self.channel or channels, what else would it be? What else does it receive? It would also be a wf point, we are also going to set the sampling, the width of the sampling, recording, then we put seps here, let's see, here it is, here it is, here it is, perfect once we have it here we see that it receives whole data so what are we going to pass there we are going to pass audio the variable that we define above.get sam sips is going to take the size of the sample we open and close parentheses and put self and we pass the format that is going to be of type fail audio perfect ready then once we have this we are also going to set the frames we are going to put here wf point frame ready open and close parentheses and here we pass the point rate sample perfect, we give an enter and it is also time to pass it it is also time to write the frames, sorry, we put here write frames, we open parentheses and here we put a b and we are going to concatenate with join, join and we pass the frames, ok, that the frames, because it is the list that we define above and we pass it there ready then that we would need to close this we put a close and ready on this side we have already finished this function well we are going to do another function we are going to do another function I am going to copy this that is here I am going to paste it here and I am going to eliminate all this and I only stay with it inside ok then what is this function going to do this function will transcribe the audio ok we put here the following transcribe that receives receives the audio route that we put self and here we have audio or we are going to put the route route audio ready then that would be enough to do here we are going to define a variable already to put r we put sr sr because because we call it the import we call it as sr ready sr point rey with ice we go here rey with ice we open and close parentheses and here we give an enter and we do audio file a variable any you put the name you want that I put audio file after this sr point audio file receives the audio route this audio route ok perfect and right now we are going to write or get the audio source so we put readAudioFile and we have here asSource two points and we put here audio equal to r.record and it receives the source ready once done this we go here to do the following, define a variable of any, I'm going to put text and where we are going to save the text that we are going to transcribe, we put riconizer, riconizer google, ready and that receives, receives the audio and also receives the language in our case as it is Spanish because we are going to put it here is ready that would be enough to make a conditional then we are going to define what we are going to do if text has something it means that it transcribed it then we put here a rich rich and to put state I am going to put it as you are I am going to put here also a message and I will say the following transcribed audio in a successful way and we also need to return the audio that transcribes the text, then we put here text will be equal to text ready if this is not fulfilled means that not transcribed it then the logical thing would be to return it also something we are going to put it here I am going to put this here and I am going to put the state it puts it as failed and I am going to put it here it could not be transcribed the audio and the text would call ready that it would not be enough to be there here here we already have the set but then it would be an error occurred when transcribing transcribing the audio ready and well that we would do in the function above this function that is here that we are going to call in this recording function where we are going to call it down there and we are going to return everything then down here we are going to call the other function we put here a result and we put equal to self point and we call the function to transcribe audio that receives remember that it receives the route we put the audio route point is worth we put audio route in this in this call to the function and we are going to make a conditional if the result we have and result its state is equal to success results equal to sources means that he got the text and transcribed it then here we are going to do a rito we are going to do a rito and we put here, status, success, message, process, culmination, culmination with success, and then we need to see the text, we put the text here, the text will be equal to the text result if not, if this did not happen, we are going to return it, we are going to return it here, we are going to return that the state was failed and we put it here, the process could not be successfully completed and we do not return anything in text ready friends that we would lack here here we would already lack to make use of the function then we are going to stop outside we close we are going to close here this here not here and we close this one here we put outside then it receives the format and that format to do this type pay audio point and 16, we are going to put 16 only, it also receives the channels, how many channels are we going to record, we are going to record at 2 in this case, also the sample rate, sample rate, in my case I am going to put it 44,100, 44,100 those who know more about music will understand that part here here the size of the buffer size buffer buffer size that I am going to put 1024 also that more the duration in this case we are going to make a text an audio test that is not so long then I'm going to put I'm going to put 15 seconds because 15 seconds audio duration also the file route file route that is how you want to call it I'm going to put it so that they save it in the same folder where I am going to put audio recording.wav ready and what else here we already make use of the function that is to put here transcribe and call the class is called transcribe and receives all those parameters that are there first the channel first the format then the channel rate sample buffer size duration of the recording and the file route also receives it ready then we are going here to print this write point and call the audio recording function ready and it would only be enough to test this code so we are going to do a little review, the first thing we did was create this function to record ready that is here then we create the function to transcribe the audio the class receives these default parameters we pass them here and then we are going to try then we are going to go up here I am going to put python here recording point pit we give an enter and we hope that the recording option comes out hello we have started recording a test for the jcva channel ready we see that the recording finished and shows us the result down here then it says here it tells us states so message process combined with success says hello we have started to record a test for the jcva channel and good friends we see that it was successful I hope you have learned a lot that you can apply for different things you can make it not only end with that but to continue asking if you want to record if you want to transcribe something longer or an audiobook or whatever you want all that you can do in this way that I just teach, I hope it has been useful and well, see you next time, remember to subscribe for more content, see you
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