Esphome uses mqtt to send and play audio

Hello, everybody!

I want to use mqtt to send audio and play it on another esp32, but the received audio is very noisy and the tone becomes baby sounds.

send code:

microphone:
  - platform: i2s_audio
    id: external_mic
    adc_type: external
    pdm: false
    i2s_audio_id: i2s_in
    i2s_din_pin: GPIO33 #SD
    bits_per_sample: 32bit
    use_apll: false
    sample_rate: 16000
    channel: right
    on_data:
      - lambda: |-
          for (uint16_t byte : x) {
            id(audio_buffer).push_back(byte);
          }
          if(id(audio_buffer).size() >= 256){
            id(mqtt_client).publish_json("call/message", [=](JsonObject root) {
              root["key"] = "audio";
              JsonArray audio_data = root.createNestedArray("data");
              for (size_t i = 0; i < id(audio_buffer).size(); i++) {
                uint8_t value = static_cast<uint8_t>(id(audio_buffer)[i] >>8);
                audio_data.add(value);
              }
            });
            id(audio_buffer).clear();
          }

receive code:

speaker:
  - platform: i2s_audio
    i2s_audio_id: i2s_out
    dac_type: external
    i2s_dout_pin: GPIO13
    mode: mono
    id: speaker_audio

mqtt:
  broker: 192.168.6.8
  discovery: False
  reboot_timeout: 0s
  id: mqtt_client
  on_json_message:
    topic: call/message
    then:
      - lambda: |-
          if (x.containsKey("key") && x["key"] == "audio" && x.containsKey("data")) {
            std::vector<uint8_t> speaker_buffer;
            for (size_t i = 0; i < x["data"].size(); i++) {
              uint8_t value = x["data"][i];
              speaker_buffer.push_back(value);
            }

            id(speaker_audio).play(speaker_buffer.data(),speaker_buffer.size());
            speaker_buffer.clear();
          }

this code is work good for me, double

speaker_buffer.push_back(value);
speaker_buffer.push_back(value);

speaker:
  - platform: i2s_audio
    i2s_audio_id: i2s_out
    dac_type: external
    i2s_dout_pin: GPIO13
    mode: mono
    id: speaker_audio

mqtt:
  broker: 192.168.6.8
  discovery: False
  reboot_timeout: 0s
  id: mqtt_client
  on_json_message:
    topic: call/message
    then:
      - lambda: |-
          if (x.containsKey("key") && x["key"] == "audio" && x.containsKey("data")) {
            std::vector<uint8_t> speaker_buffer;
            for (size_t i = 0; i < x["data"].size(); i++) {
              uint8_t value = x["data"][i];
              speaker_buffer.push_back(value);
              speaker_buffer.push_back(value);
            }

            id(speaker_audio).play(speaker_buffer.data(),speaker_buffer.size());
            speaker_buffer.clear();
          }