Romkabouter / ESP32-Rhasspy-Satellite

The repo has implementing an esp32 standalone MQTT audio streamer. Is is desinged to work as a satellite for Rhasspy (https://rhasspy.readthedocs.io/en/latest/). It supports multiple devices
GNU General Public License v3.0
360 stars 64 forks source link

M5 Atom Echo quiet microphone #63

Open whinis opened 3 years ago

whinis commented 3 years ago

I alluded to this issue in https://github.com/Romkabouter/ESP32-Rhasspy-Satellite/issues/53 and think I may have found the issue for this but cannot confirm the comment. The following code is as mentioned in the previous example from issue directly from the example however on the bits per sample there is a comment saying even though its set to 16 bit it's fixed at 12 bit.

i2s_config_t i2s_config = { .mode = (i2s_mode_t)(I2S_MODE_MASTER), .sample_rate = 16000, .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, // is fixed at 12bit, stereo, MSB .channel_format = I2S_CHANNEL_FMT_ALL_RIGHT, .communication_format = I2S_COMM_FORMAT_I2S, .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, .dma_buf_count = 6, .dma_buf_len = 60, };

It doesn't really sense for the mic to be stereo in this case and from what I can tell from the amplifier datasheet it also doesn't make much sense so is likely either a copied comment from something else whenever they made the example or a software limitation of the SDK.

Going on the idea it was 12 bit and not 16 bit I tried to multiply the audio by various powers of 2 initially just to increase the loudness but was all overly loud and led to clipping. Trying to multiply by anything except a power of 2 leads to a crash that I cannot pin point.

I sadly lack the audio knowledge to figure out if its actually taking the PDM audio and making it 12 bit or 16 bit but a gain function would be nice. However due to the relative lack of power in the esp32 I am unsure if its smarter here or at rhasspy.

Romkabouter commented 3 years ago

Nice find, I have no idea if this could cause the issue. In any case it is a strange comment indeed and I will see if I can find some more info on it. Thanks