My main purpose is to change the pitch of the my voice and then input it to a voice room/voice call say like a zoom call or a hangouts meeting without playing it back to me.
I found 2 questions on a similar topic: 1. Playing mp3 file through microphone with python 2. How to play MP3 files into the microphone input jQuery
But these ones do not answer the question appropriately.
Something similar to this: https://github.com/jremmons/pyfakewebcam/blob/master/pyfakewebcam/pyfakewebcam.py
but for microphones?
You can use sounddevice, just tested it on Windows 10
you can create a stream and read data while as it records, naturally you will have a latency proportional to the size of the chunk you read.
This example records 6.4 seconds of audio at 16kHz. After finished you call the method stop. Each chunk in this example has 1024 samples corresponding to 64 milliseconds.
micStream = sd.InputStream(samplerate=16000, blocksize=1024, channels=1, dtype='float32')
micStream.start();
CHUNK_SIZE = 1024
NCHUNKS = 100
wavData = np.zeros(CHUNK_SIZE*NCHUNKS)
for i in range(0, NCHUNKS):
chunkData, overflowed = micStream.read(CHUNK_SIZE);
wavData[i*chunk:(i+1)*chunk] = np.mean(chunkData, axis=1) # ensure to be mono
micStream.stop()
plt.plot(wavData)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With