Closed rjam-xav closed 3 years ago
update: the REC file created is empty
wow, I had same problem some days ago, and asked about this issue thread
The key to achieve the correct pipeline working - to have separate pipelines for each process, separate audio_elements,
like this
`void system_init_fatfs() { ESP_LOGI(TAG_SYSTEM, "fatfs initialisation"); audio_board_sdcard_init(periph_handle, SD_MODE_1_LINE);
fatfs_stream_cfg_t fatfs_cfg_reader = FATFS_STREAM_CFG_DEFAULT();
fatfs_cfg_reader.task_prio = 8;
fatfs_cfg_reader.type = AUDIO_STREAM_READER;
fatfs_stream_reader = fatfs_stream_init(&fatfs_cfg_reader);
fatfs_stream_cfg_t fatfs_cfg_writer = FATFS_STREAM_CFG_DEFAULT();
fatfs_cfg_writer.task_prio = 8;
fatfs_cfg_writer.type = AUDIO_STREAM_WRITER;
fatfs_stream_writer = fatfs_stream_init(&fatfs_cfg_writer);
}`
and this
`audio_pipeline_handle_t pipeline_i2s_to_uSD; audio_pipeline_handle_t pipeline_uSD_to_i2s; audio_pipeline_handle_t pipeline_i2s_to_http;
esp_periph_set_handle_t periph_handle; esp_periph_set_handle_t periph_set_microphone; esp_periph_handle_t led_handle; esp_periph_handle_t wifi_handle;
audio_element_handle_t fatfs_stream_writer; audio_element_handle_t fatfs_stream_reader; audio_element_handle_t i2s_stream_writer; audio_element_handle_t i2s_stream_reader_to_sd; audio_element_handle_t i2s_stream_reader_to_http; audio_element_handle_t mp3_decoder; audio_element_handle_t wav_encoder; audio_element_handle_t http_stream_writer;`
Also, I think there could be only one audio_event_iface_set_listener, because I can't set it for different pipelines in different places
thank you so much, I tried doing this through separate pipelines but had a problem switching between the two and resource availability of resources. Will look at this again. Are you able to keep all your different pipelines running at the same time? or do you need to free up resources? what about starting up the codec/SDCard? the same peripheral can be added to different pipelines and kept running simultaneously?
This time all my audio elements are separate but my pipeline is the same.
@rjam-xav, I'm using different thread, to control microphone recording
` void microphone_record(void *par) { while (1) { if (needToRecordSeconds > 0) { ESP_LOGI(MICROPHONE_TAG, "[3.6] Set up uri (file as fatfs_stream, wav as wav encoder)"); audio_element_set_uri(fatfs_stream_writer, "/sdcard/rec.wav");
ESP_LOGI(MICROPHONE_TAG, " Start recording");
audio_pipeline_run(pipeline_i2s_to_uSD);
ESP_LOGI(MICROPHONE_TAG, "[ * ] Recording ... %d", needToRecordSeconds);
vTaskDelay(pdMS_TO_TICKS(1000 * needToRecordSeconds));
ESP_LOGI(MICROPHONE_TAG, "Stop audio_pipeline");
audio_pipeline_stop(pipeline_i2s_to_uSD);
audio_pipeline_wait_for_stop(pipeline_i2s_to_uSD);
needToRecordSeconds = 0;
}
vTaskDelay(pdMS_TO_TICKS(100));
}
} `
also, I'm initialising it in separate file, easier to control what required for each pipeline
`
void system_init() { esp_log_level_set(TAG_SYSTEM, ESP_LOG_INFO);
ESP_LOGI(TAG_SYSTEM, "initialisation");
system_init_periph();
system_init_led();
system_init_wifi();
system_init_fatfs();
system_init_http();
system_init_uart();
system_init_mp3();
system_init_wav();
system_init_i2s();
system_init_i2s_to_sd_pipeline();
system_init_sd_to_i2s_pipeline();
system_init_i2s_to_http_pipeline();
} `
Also, try to check log. It creates header for wav file at the stopping of pipeline, so, it should reach this point after some time of recording
ESP_LOGI(TAG, "[ 6 ] Stop audio_pipeline"); audio_pipeline_stop(pipeline); audio_pipeline_wait_for_stop(pipeline);
Interesting. I need to be able to keep looping between the wakenet and recording serially. Much like you enter a query for alexa/siri. But I have also realized that the write to file for wav only occurs after the pipeline stops. Is it possible to restart the pipeline without having to relink elements ?
Not sure, not using wakenet. For me it's better to keep different pipelines, to avoid any relink.
Hello,
I am trying to test a basic functionality by integrating the examples from asr and recorder to use hi Jeson to wakeup and then recording. My code is below:. I am able to iteratively listen and have the recording countdown begin but then the REC file is generated though it is unreadable. Since I can iterate over the wakenet and recording without error, I am unsure where the error is coming from? is the pipeline not proceeding to the wav encoding and fstream write? if so why is that the case?