mbsantiago/soundevent

Enhancement Proposal - Adding FLAC File Support to load_audio Function

Closed this issue · 0 comments

Description

This enhancement aims to extend the functionality of the load_audio function to include support for additional audio file formats, with a specific focus on FLAC files. The objective is to maintain the current API while efficiently handling the loading of compressed audio formats and allowing users to specify subsets of the audio.

Requirements

  • Minimize Dependencies
    Be cautious about introducing additional dependencies. If necessary, include them as optional dependencies in the pyproject.toml metadata file under the audio group or another suitable.

  • Refactor soundevent.audio.io.load_audio Function
    Restructure the load_audio function to dynamically use different audio loaders based on the file format.

  • File Format Identification Function:
    Create a function to identify the format of the audio file, enabling the appropriate loader selection.

  • Maintain API Compatibility:
    Ensure that the enhanced load_audio function retains the same API, including parameters such as offset and samples. It is crucial that users can request a subset of the audio, and the function returns the correct subset.

  • Update is_audio_file Function:
    Modify the soundevent.audio.files.is_audio_file function to recognize and accept FLAC files.

  • Implement get_media_info Function for FLAC:
    Extend the soundevent.audio.media_info.get_media_info function to provide media information for FLAC files. Ensure that the file format is correctly detected, and the appropriate media info reader is used. Performance here is paramount and it should be able to extract the info without reading the whole file.

  • Unit Testing:
    Implement comprehensive unit tests to verify that the API remains consistent and that the load_audio function correctly returns the desired audio subset for FLAC files.

Challenges

  • Handling Compressed Formats:
    Address the challenge posed by compressed formats like FLAC. Develop a solution that allows reading only a subset of the audio file without the need to decompress the entire file. This is essential for optimizing performance, especially when dealing with large audio files.

Hints and Guidelines

Contributor

Thanks to @alvarovegahd for proposing this enhancement.

If you have any questions or suggestions, feel free to discuss them here.