File: backend_utils.py

package info (click to toggle)
pytorch-audio 0.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,592 kB
  • sloc: python: 41,137; cpp: 8,016; sh: 3,538; makefile: 24
file content (21 lines) | stat: -rw-r--r-- 533 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import unittest

import torchaudio


def set_audio_backend(backend):
    """Allow additional backend value, 'default'"""
    backends = torchaudio.list_audio_backends()
    if backend == "soundfile":
        be = "soundfile"
    elif backend == "default":
        if "sox_io" in backends:
            be = "sox_io"
        elif "soundfile" in backends:
            be = "soundfile"
        else:
            raise unittest.SkipTest("No default backend available")
    else:
        be = backend

    torchaudio.set_audio_backend(be)