Audio-Spectrum-Analyzer-in-Python
Audio-Spectrum-Analyzer-in-Python copied to clipboard
It is not showing my live speech wave form
whenever I ran the code it is showing continuous wave forms without having any input.After connecting michrophone also it is giving the same waveforms always(oscillations). How can I make it take my live speech and show it as wave form. Thanking you
What is the actual issue?
I am also facing the same issue. Waveforms are shown on the screen but they are not the waveforms of live audio stream from the microphone, they are just random noise. Giving any input from microphone does not make any difference in the waveform on the screen.
I seem to have fixed the issue. You have to setup the microphone, I believe that's what you do, I'll upload my version of the code which works when you have a mic setup.
What do you mean by mic setup exactly? I have used mic with pyaudio before and it worked just fine. But here it is not able to properly visualize the waveform so I think some changes in the visualization part of the code is required. One of the main issue is the waveform is choppy. It does not show the continuous form the waveform properly. I have tried changing mic as well but still the waveforms are not proper.
mic 1
mic2
I was able to find the workaround for this issue. As mentioned in #2 , instead of using 2 step conversion from audio data to numpy array I used the single step converstion along with the offset of 128. But in addition to that I scaled the the whole array with the max value so that waveform can be visualized within range.
data_np = (np.frombuffer(data, dtype='<i2') / max(data)) + 128
NOTE: Also make sure that the input volume of microphone is high enough to capture the audio signal.
I don't know if this will work for y'all, but I stumbled across this stack overflow article, and the fix there resolved this issue for me: https://stackoverflow.com/questions/62656790/input-overflowed
data = stream.read(CHUNK,exception_on_overflow = False)
sorry haven't used this code in ages. But from what i remember, "setup the mic" means setting the microphone you're using as the default microphone such that pyaudio recognises this mic and automatically gathers audio data from the mic your using. This is something you have to do in your OS settings and it's got nothing to do with pyaudio