MAC M3 audio backend no longer appearing
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 799
- Avg merge
- 58m
- Merged PRs (30d)
- 3
Description
🐛 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce with torch==2.3.0 and torchaudio==2.3.0 on an M3 Mac, then inspect the backend-discovery path exposed by torchaudio.list_audio_backends() and the stream-loading calls in the report. Done means an appropriate backend is listed and the provided BytesIO workflow no longer raises the reported RuntimeError, with the behavior checked against the Colab case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100