You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
I think I have figured out a solution but don't have time to properly test what I've done. I've followed the advice here: https://pytorch.org/audio/stable/build.linux.html in a fresh conda environment, including the "[Optional] Build TorchAudio with a custom built FFmpeg" section. I've just change the line to install ffmpeg to conda install -c conda-forge ffmpeg=6 (i.e., I've specified that the ffmpeg libraries should come from ffmpeg 6.something).
🐛 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()
Versions
torch==2.3.0
torchaudio==2.3.0
The text was updated successfully, but these errors were encountered: