Python audio recording ? [Solved] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Python audio recording ? [Solved]

I want an audio recording library that can be packed into an exe(not C# wrapper or .NET), i searched for the following: Can PyAudio be packed as exe ? No Can python SoundCard be packed as exe ? Nothing Python audio library that accepts portable dlls ? No Python portaudio binding (not pyaudio) ? No Can i load everything from dll without knowing the symbol names ? No (because i don't know how to work with portaudio C++) DirectSound COM object ? Only description and they never gave a code example that loads a COM object DirectSound and vbscript ? Nothing Pywin32 directsound? The only example available on github is about audio processing not recording So is there is any library that can record audio and can be packed as an exe ? Here's the solution with a portable dll for both 32 and 64 bit which doesn't require installing portaudio : https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio

15th May 2020, 7:56 PM
WARLORD
WARLORD - avatar
8 Answers
+ 1
WARLORD i think you are missing port audio dependency. Are you using linux? In linux you can use this command " sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio" to install the dependency.
20th May 2020, 3:22 AM
Learn11
+ 2
Divya Peddapalyam i think you haven't read or understood what i'm asking for ?
17th May 2020, 1:35 PM
WARLORD
WARLORD - avatar
+ 2
Learn11 yes which is portaudio.h not found That's why i wrote my search results above Btw i tried to find a version that accepts portable dlls so i can fork it but there was nothing in the results as shown above
20th May 2020, 1:39 AM
WARLORD
WARLORD - avatar
+ 2
Learn11 no i'm using windows and if i didn't have portaudio i wouldn't even import pyaudio
20th May 2020, 8:29 AM
WARLORD
WARLORD - avatar
+ 2
Learn11 i have MinGW and portaudio installed Does pyinstaller pack the hole c library in ~/incude ,because it creates a fake c lib
20th May 2020, 8:43 AM
WARLORD
WARLORD - avatar
+ 2
Learn11 anyway thanks for helping and here's a "best answer", have a nice day :)
21st May 2020, 10:01 PM
WARLORD
WARLORD - avatar
+ 1
Have you tried packing pyaudio to exe? Any errors?
19th May 2020, 8:11 PM
Learn11
0
PyAudio provides Python bindings for PortAudio, the cross-platform audio I/O library. With PyAudio, you can easily use Python to play and record audio on a variety of platforms, such as GNU/Linux, Microsoft Windows, and Apple Mac OS X / macOS.As you may have noticed, playing sounds with pyaudio is a bit more complex than playing sounds with the libraries you’ve seen earlier. This means that it may not be your first choice if you just want to play a sound effect in your Python application.However, because pyaudio gives you more low-level control, it is possible to get and set parameters for your input and output devices, and to check your CPU load and input or output latency.It also allows you to play and record audio in callback mode, where a specified callback function is called when new data is required for playback, or available for recording. These options make pyaudio a suitable library to use if your audio needs go beyond simple playback. import pyaudio import wave filename = 'myfile.wav' # Set chunk size of 1024 samples per data frame chunk = 1024 # Open the sound file wf = wave.open(filename, 'rb') # Create an interface to PortAudio p = pyaudio.PyAudio() # Open a .Stream object to write the WAV file to # 'output = True' indicates that the sound will be played rather than recorded stream = p.open(format = p.get_format_from_width(wf.getsampwidth()), channels = wf.getnchannels(), rate = wf.getframerate(), output = True) # Read data in chunks data = wf.readframes(chunk) # Play the sound by writing the audio data to the stream while data != '': stream.write(data) data = wf.readframes(chunk) # Close and terminate the stream stream.close() p.terminate() <*************SINCERE REQUEST ,I JUST STARTED WITH SOLO LEARN.COM..SO PLEASE UPVOTE MY ANSWER AS WELL AS ALL CODES WHATEVER YOU LIKE IN MY PROFILE...THANK YOU***********>
16th May 2020, 5:10 AM
Divya Peddapalyam
Divya Peddapalyam - avatar