Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAC M3 audio backend no longer appearing #3785

Open
tval2 opened this issue May 8, 2024 · 1 comment
Open

MAC M3 audio backend no longer appearing #3785

tval2 opened this issue May 8, 2024 · 1 comment

Comments

@tval2
Copy link

tval2 commented May 8, 2024

馃悰 Description

I get "RuntimeError: Couldn't find appropriate backend to handle uri <_io.BytesIO object at 0x13f1f8450> and format None." when processing basic audio data on my mac but not on my colab notebook.

Full code is here
`import torchaudio
print(torchaudio.list_audio_backends())
def read_audio_from_stream(audio_stream, sampling_rate: int = 16000):
sox_backends = set(['sox', 'sox_io'])
audio_backends = torchaudio.list_audio_backends()

if len(sox_backends.intersection(audio_backends)) > 0:
    effects = [
        ['channels', '1'],  # Force mono
        ['rate', str(sampling_rate)]  # Resample to the target sampling rate
    ]

    wav, sr = torchaudio.sox_effects.apply_effects_file(audio_stream, effects=effects)
else:
    # Load the audio file from the stream
    wav, sr = torchaudio.load(audio_stream)

    # If more than one channel, take the mean to make it mono
    if wav.size(0) > 1:
        wav = wav.mean(dim=0, keepdim=True)

    # Resample if necessary
    if sr != sampling_rate:
        transform = torchaudio.transforms.Resample(orig_freq=sr, new_freq=sampling_rate)
        wav = transform(wav)
        sr = sampling_rate

assert sr == sampling_rate, "Sampling rate does not match the target sampling rate"
return wav.squeeze(0)  `

where torchaudio.list_audio_backends() always prints to empty []. I tried uninstalling and then reinstalling with `pip install torch torchaudio -f https://download.pytorch.org/whl/torch_stable.html`, I also installed sox. ffmpeg is already installed on my mac. I've seen this pop up on stack overflow 3 times this month as well but no one has come up with an answer. It seems pretty trivial to work for torchaudio.

Versions

torch==2.3.0
torchaudio==2.3.0

@eisneim
Copy link

eisneim commented May 25, 2024

same here, reinstall ffmpeg:

brew install ffmpeg@6
brew install sox

then reinstall torchaudio won't work, torchaudio.list_audio_backends() always prints to empty []

hardware: mac osx m3 max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants