Open dmfaber1 opened 3 years ago
Do you know which PyAudio I should download?
Trying Python. Opens in: "The prompt >>> on the last line indicates that you are now in an interactive Python interpeter session, also called the “Python shell”. This tutorial are intended to be run in a shell (also called a terminal or console)."
How do I run in shell (also called a terminal or console)? Ctrl-Z or exit() just closes the window.
Do you know which PyAudio I should download?
So now that you have the Ubuntu WSL working, this opens up more possibilities. The preferred way would be to download the Linux one, and use the Ubuntu WSL to build and run it. But I am not sure that Windows shares the Audio Devices with the Ubuntu WSL. If it doesn't, than the Linux one doesn't really help us and we will have to use the Windows one, which requires the more complicated mingw compilation. Let me try this one out first so I know what would work better.
Trying Python. Opens in: "The prompt >>> on the last line indicates that you are now in an interactive Python interpeter session, also called the “Python shell”. This tutorial are intended to be run in a shell (also called a terminal or console)." How do I run in shell (also called a terminal or console)? Ctrl-Z or exit() just closes the window.
So if you create a .py file with python code inside it, you can just call python that_file.py to execute it in the shell. Just opening up powershell should let you do this, I believe the Windows Python installation set up all the links for this to work.
I will also create a new issue for helpful stuff for learning Python, specifically using VSCode to make modifying and running python code super easy.
So to go through the steps we did to test out the portaudio on your laptop, but on your raspberry pi:
cd ~/Downloads
wget http://files.portaudio.com/archives/pa_stable_candidate_v190700_20210307.tgz
If you don't have wget installed, just install it first
sudo apt update && sudo apt install wget
tar -xzf pa_stable_candidate_v190700_20210307.tgz
sudo apt update
sudo apt install libasound-dev
sudo apt install build-essential
cd portaudio
./configure && make
sudo make install
sudo apt install python3
sudo apt install pip3
pip3 install PyAudio
python3 testPyAudio.py sample.wav
Executed #1 to 7. Everything went smoothly
I pushed some code - mostly just copy pasted examples. So if you copy test_pyaudio.py and Ring01.wav to your raspberry pi, you should be able to run python3 test_pyaudio.py Ring01.wav
. So this should play the ring noise if you have a sound device connected. But really the first thing is just to see what happens when run, ie does it run with no errors?
Do you have a usb headset/mic? That would be the next interesting thing, if it uses the default audio device correctly or if we need to tweak some code when opening the audio stream.
The other thing I pushed was some guys code for doing just what we are trying https://www.instructables.com/Raspberry-Pi-Guitar-Tuner/. I cleaned it up a bit so it hopefully can be used. Would be interesting to see what happens.
PyAudio seems like one of the best tools to analyze an audio stream using Python: https://pypi.org/project/PyAudio/
This is just a python interface to PortAudio, which needs to be installed to actually use PyAudio: http://www.portaudio.com/
PortAudio is cross platform, so it is a good audio stack to utilize, as we can test on Windows, and deploy to RaspberryPi (Linux). Installing PortAudio on Linux is pretty straightforward (http://files.portaudio.com/docs/v19-doxydocs/compile_linux.html):
On Windows (http://files.portaudio.com/docs/v19-doxydocs/compile_windows_mingw.html), it is a bit more complicated, because you will need to install a compiler (http://mingw-w64.org/doku.php). Or we can just try using the WSL again.
Once PortAudio is installed, PyAudio can be installed:
pip install PyAudio
Example of a simple Spectrum Analyzer using PyAudio: https://gist.github.com/netom/8221b3588158021704d5891a4f9c0edd