Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 I2S Wifi Michropohne #55

Open
galzoltan42 opened this issue Sep 27, 2024 · 1 comment
Open

ESP32 I2S Wifi Michropohne #55

galzoltan42 opened this issue Sep 27, 2024 · 1 comment

Comments

@galzoltan42
Copy link

galzoltan42 commented Sep 27, 2024

My respect! You have this great project: https://0110.be/posts/ESP32_I2S_WiFi_Microphone , and I would like to ask if it is possible to do continuous reading of a UDP microphone in python? The code below does not work:
(The phenomenon: a strong humming sound, the hum is stronger during speech)

`def udp_pcm_to_audio(data):

wav_io = io.BytesIO()
with wave.open(wav_io, 'wb') as wav_file:
    wav_file.setnchannels(1) 
    wav_file.setsampwidth(2) 
    wav_file.setframerate(44100) 
    wav_file.writeframes(data)
wav_io.seek(0)
return wav_io`

This works perfectly, so all ESP32, microphone, UDP settings are good:
nc -l -u 3000 | ffmpeg -y -f f32le -ar 16000 -ac 1 -i pipe: microphone.wav

Thank you very much for your help!

@JorenSix
Copy link
Owner

JorenSix commented Oct 3, 2024

Good to hear you find some use for it!

For the Python implementation you may need to make sure the correct wav format is used: in this case 16kHz, 32bit float samples, mono. Especially the 32bit float samples are a bit uncommon so this needs to be specified explicitly, otherwise a 32bit int might be used.

In your code you set the sample rate to 44.1kHz while it should be 16kHz. Also the sample format should be checked: make sure you use 32bit float with the wave.open API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants