Audio-Spectrum-Analyzer-in-Python icon indicating copy to clipboard operation
Audio-Spectrum-Analyzer-in-Python copied to clipboard

It is not showing my live speech wave form

Open lio14cha opened this issue 7 years ago • 7 comments

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

lio14cha avatar Sep 12 '18 14:09 lio14cha

What is the actual issue?

rudrathegreat avatar Oct 27 '18 04:10 rudrathegreat

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.

Nukul13 avatar May 07 '20 04:05 Nukul13

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.

rudrathegreat avatar May 07 '20 10:05 rudrathegreat

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. Screenshot from 2020-05-08 08-41-48 mic 1

Screenshot from 2020-05-08 08-53-52 mic2

Nukul13 avatar May 08 '20 03:05 Nukul13

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.

Nukul13 avatar May 08 '20 07:05 Nukul13

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)

putmanj00 avatar Jul 09 '22 03:07 putmanj00

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

rudrathegreat avatar Jul 09 '22 03:07 rudrathegreat