How to Record Audio and Graph wave .wav files using Python!
ฝัง
- เผยแพร่เมื่อ 15 มิ.ย. 2022
- Code available here:
github.com/ple...
This is a quick and easy Python tutorial where I show you how to use several great Python modules and packages to record audio through a microphone or audio device on your computer with the PyAudio Python Module. I then show you how to process the data using the WAVE .wav file audio editing module. Lastly I show how to graph and display the recorded file using the numpy and matplotlib python plug in modules.
Love the content on this channel? Feel free to support me on Patreon!
/ lemastertech
What do you want to see in a future video? Be sure to leave a comment below saying what you want in future videos or letting me know if you had any questions about this tutorial!
Thanks for watching, and be sure to leave a like or subscribe to the channel to stay up to speed with all our future projects! - วิทยาศาสตร์และเทคโนโลยี
Excellent video. Terrific topic. Like having the code already typed out. That way I don't have to listen to clickity-clackity key presses and watching misspelled words retyped. Thank you very much.
Thank you for the kind comment! I appreciate your feedback an I'm glad you liked the video!!
Thanks for the great and quick information! keep making such content!
Thanks for the nice comment!! I will keep it up for sure :)
Interesting video as usual, I prefer the tutorials where we can follow along, but it did make a nice change. Keep it up, road to 5k! Have you considered setting up on Patreon?
Hi Dale! Glad you found this one interesting, and I think the follow along line by line format is more fun for me to make and feels more natural too, I just got a little slammed with my day job this week haha. Thanks for the comment!! I have not thought much about a Patreon but that’s an interesting concept!! I could maybe do some complete games or in depth tutorials for patreon supporters in addition to the stuff on TH-cam! Neat idea, I’ll have to look into it!
You don't need to change the dtype to 32bit for stereo, and doing that just increases the resolution / precision of what is recorded. You need to change shape of the np array so it is two dimensional, one per channel, but each can use int16 no problem. Some hardware doesn't support 32bit so this might be important.
Thank for the clarification hopefully some others can find this comment useful too!
Exactly what I needed for my project. Just wondering whether it is possible to set the audio input as a web browser or application like Zoom/Teams instead of a microphone?
Hello! Yes this same type of application would definitely be possible but it would be considered much more capturing computer audio rather than recording through a microphone. There isn’t really a sound input device in this case and it would need to basically record the audio from another app!
very nice! really nice python audio tutorials, thanks
You are welcome! Thanks for the feedback!
Hello! do you know if instead of recording I can upload an audio file (mp3) and then analyze it?
Hi! Yes rather than recording and then analyzing a live audio clip just import, possibly convert to wav since it’s easier to pick apart and then analyze!
Can you use miliseconds as opposed to seconds?
Probably! Sorry this project was along time ago and I’m not sure off the top of my head!
Thank you so much. Also is there any way that a waveform once plotted can be converted to an audio file and saved to the device?
Hello, yes it is - I believe in this video we save the waveforms as a .wav file which can be easily converted to an mp3 or other playable audio file. I know this video was a long time ago but I believe what you’re asking for is in this video
hi thats was a nice videos, i want to ask, can we crop the audio using python? i mean split the full audio itu seconds?
You can! You just select which “frames” of the raw audio recording you want, and either cut the rest out or store it somewhere else. The frames variable is what you need to manipulate for that
Your video project is excellent! Thanks for making it. I tried installing the pyaudio module and get the no module found error. Doing a pip list shows it's there but the name was PyAudio. I'm wondering if the video use a different version of the module than the one I picked up?
Hi, sometimes this is because pip might install to a generic location on your C/ folder but depending on the IDE you use you might need to install to your specific project folder so rather than c/ pip install pyaudio the command would be like c/program files/pycharm/recordproject pip install pyaudio and actually direct pip to this project! Goodluck!
@@lemastertech Thanks for the advice! Yesterday I tried changing the selected interpreter on the VS and that seemed to work pyaudio was happy. Directing pip to a particular project is cool. I didn't know that was possible. I should do that all the time.
Is it possible to Write a function which takes an audio file as an input and outputs the vowel as a string from a recorded WAV file? Like, if I was supposed to detect the vowels from my recorded audio speech sample WAV file...
Hi! You could do that if you used a speech to text API! I suggest using someone like assemblyAI who has a free API you can get from their website! They will translate an audio recording to text then you can sort the text just like you’d sort a string! Good luck!
Support ❤️❤️
Thanks for the support!!
can you explain for me about b' ' join. I forgot what does b' ' in Python means? Thank you !
Hi, what part of the video are you looking at? Can you share a timestamp where this pops up? I don’t fully understand what you’re asking?
b" " is a notation for binary sequence. As you can see, above the statement a wav file opened with "wb" argument, that is writing in binary. Hence you need to write in binary format inside the file opened.
line by line, plz😊
Hi! I probably won’t do this particular one line by line since it’s been a while since I did this project but I am working on some more tutorials on sound processing soon!! 😊
Hi 👋
Hi buddy!