feature request: support for uploading .m4a audio files #2151

Closed
opened 2025-11-11 15:01:13 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @gjgd on GitHub (Sep 21, 2024).

Is your feature request related to a problem? Please describe.
When I upload a .m4a file for transcription, I get the following error
CleanShot 2024-09-21 at 15 35 16@2x
CleanShot 2024-09-21 at 15 34 31@2x

Describe the solution you'd like
I would like .m4a type to be supported, currently I have to convert the file to .mp3 before I can upload it

Originally created by @gjgd on GitHub (Sep 21, 2024). **Is your feature request related to a problem? Please describe.** When I upload a .m4a file for transcription, I get the following error <img width="328" alt="CleanShot 2024-09-21 at 15 35 16@2x" src="https://github.com/user-attachments/assets/eff470fb-6386-4f84-940a-c795582a28fc"> <img width="403" alt="CleanShot 2024-09-21 at 15 34 31@2x" src="https://github.com/user-attachments/assets/40b1f111-0d43-4efe-adb7-508ba3a4974c"> **Describe the solution you'd like** I would like .m4a type to be supported, currently I have to convert the file to .mp3 before I can upload it
Author
Owner

@tjbck commented on GitHub (Sep 22, 2024):

Could you provide us with some sample files?

@tjbck commented on GitHub (Sep 22, 2024): Could you provide us with some sample files?
Author
Owner

@gjgd commented on GitHub (Sep 22, 2024):

Sure! Here are a couple, github doesn't allow sharing audio files directly but I pushed them to a git repo: https://github.com/gjgd/audio-samples

@gjgd commented on GitHub (Sep 22, 2024): Sure! Here are a couple, github doesn't allow sharing audio files directly but I pushed them to a git repo: https://github.com/gjgd/audio-samples
Author
Owner

@rgaricano commented on GitHub (Sep 23, 2024):

¿maybe? (i did`t test)

open-webui/backend/open_webui/apps/audio/main.py

Line 127
++


def is_m4a_audio(file_path):
    """Check if the given file is an M4A audio file."""
    if not os.path.isfile(file_path):
        print(f"File not found: {file_path}")
        return False

    info = mediainfo(file_path)
    if (
        info.get("codec_name") == "aac"
        and info.get("codec_type") == "audio"
        and info.get("codec_tag_string") == "audio/x-m4a"
    ):
        return True
    return False
    
def convert_m4a_to_wav(file_path, output_path):
    """Convert M4A audio file to WAV format."""
    audio = AudioSegment.from_file(file_path, format="m4a")
    audio.export(output_path, format="wav")
    print(f"Converted {file_path} to {output_path}")

Line 433
++

if is_m4a_audio(file_path):
                print("is_m4a_audio")
                os.rename(file_path, file_path.replace(".wav", ".m4a"))
                # Convert MP4 audio file to WAV format
                convert_m4a_to_wav(file_path.replace(".wav", ".m4a"), file_path)
@rgaricano commented on GitHub (Sep 23, 2024): ¿maybe? (i did`t test) open-webui/backend/open_webui/apps/audio/main.py Line 127 ++ ``` def is_m4a_audio(file_path): """Check if the given file is an M4A audio file.""" if not os.path.isfile(file_path): print(f"File not found: {file_path}") return False info = mediainfo(file_path) if ( info.get("codec_name") == "aac" and info.get("codec_type") == "audio" and info.get("codec_tag_string") == "audio/x-m4a" ): return True return False def convert_m4a_to_wav(file_path, output_path): """Convert M4A audio file to WAV format.""" audio = AudioSegment.from_file(file_path, format="m4a") audio.export(output_path, format="wav") print(f"Converted {file_path} to {output_path}") ``` Line 433 ++ ``` if is_m4a_audio(file_path): print("is_m4a_audio") os.rename(file_path, file_path.replace(".wav", ".m4a")) # Convert MP4 audio file to WAV format convert_m4a_to_wav(file_path.replace(".wav", ".m4a"), file_path) ```
Author
Owner

@tjbck commented on GitHub (Sep 24, 2024):

Added to dev.

@tjbck commented on GitHub (Sep 24, 2024): Added to dev.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#2151