您尚未登录。

#1 Re: ESP32/ESP8266 » 自己写了一个获取HTTP流,播放的程序,但播放出来全是噪音 » 2019-11-12 09:23:56

晕哥 wrote:

这是从http服务器下载数据吗?是什么格式?mp3?

pcm,采样率16000,16位单通道

#2 Re: ESP32/ESP8266 » 自己写了一个获取HTTP流,播放的程序,但播放出来全是噪音 » 2019-11-11 16:23:53

音频数据采样率为16000 16bit 单通道。写入哪里,分批写或者一次写完都全是噪音。音频数据是没问题的

#3 ESP32/ESP8266 » 自己写了一个获取HTTP流,播放的程序,但播放出来全是噪音 » 2019-11-11 16:21:30

苦逼的大白
回复: 4

音频管道初始化代码
void player_pipeline_init()
{
audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
pipeline = audio_pipeline_init(&pipeline_cfg);
mem_assert(pipeline);

raw_stream_cfg_t raw_cfg = RAW_STREAM_CFG_DEFAULT();
raw_cfg.type = AUDIO_STREAM_WRITER;
raw_writer = raw_stream_init(&raw_cfg);

i2s_stream_cfg_t i2s_cfg = I2S_STREAM_CFG_DEFAULT();
i2s_cfg.type = AUDIO_STREAM_WRITER;
i2s_stream_writer = i2s_stream_init(&i2s_cfg);

audio_pipeline_register(pipeline, raw_writer, "raw_writer");
audio_pipeline_register(pipeline, i2s_stream_writer, "i2s");

audio_pipeline_link(pipeline, (const char *[]) {"raw_writer","i2s"}, 2);

i2s_stream_set_clk(i2s_stream_writer, 16000, 16, 1);

audio_pipeline_run(pipeline);
}

获取HTTP流,播放的代码
esp_http_client_config_t config =
{
.url = request_data,
.event_handler = http_client_event_msg_t,
};
client = esp_http_client_init(&config);
esp_http_client_set_method(client,HTTP_METHOD_GET);
esp_err_t err = esp_http_client_perform(client);
if(err == ESP_OK)
{
int audio_length = esp_http_client_get_content_length(client);
char audio_data = (char )calloc(audio_length,sizeof(char));
esp_http_client_read(client,audio_data,audio_length);
if(audio_data != NULL)
{
int write_len1,write_len2,offset = 0;
while(offset<audio_length)
{
write_len1 = (audio_length-offset)>1024?1024:(audio_length-offset);
write_len2 = raw_stream_write(raw_writer,audio_data+offset,write_len1);
offset += write_len2;
ESP_LOGI(TAG,"offset = %d",offset);
}
free(audio_data);
audio_data = NULL;
}
}
esp_http_client_cleanup(client);

问题出在哪里

#5 ESP32/ESP8266 » 如何多次从不同的http地址读取音频文件。 » 2019-11-11 11:21:19

苦逼的大白
回复: 3

官方的play_http_example和百度语音合成的那个例程怎么改都只能播放一次。自己直接从HTTP获取音频文件直接播放。播放出来的又全是杂音

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn


东莞哇酷科技有限公司开发