I won't provide code since you have not shown anything at your end.
But here are high-level steps and hints to go do it.
1) Use `pyaudio blocking wire stream to read input from microphone in the form of chunks [ pieces].
2) For each chunk , apply fft
and get frequency for all the chunks and add to an array/list.
There are some useful discussion here and here
So if you have following parameters as per (1)
RATE = 44100
chunk = 1024
RECORD_SECONDS = 1
You will have 44 bins, with each bins providing one frequency after FFT
transformations.
3) You can select maximum frequency max(frequency_list)
that you get from (2) per second, Times how many seconds you wish to record.
4) Write the chunks back to stream
5) You have now frequency per second till time duration of your recording in real-time that you can play with.