/usr/lib/python2.7/dist-packages/audioread/__init__.py is in python-audioread 1.0.3-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | # This file is part of audioread.
# Copyright 2013, Adrian Sampson.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
"""Decode audio files."""
class DecodeError(Exception):
"""The base exception class for all decoding errors raised by this
package.
"""
class NoBackendError(DecodeError):
"""The file could not be decoded by any backend. Either no backends
are available or each available backend failed to decode the file.
"""
def _gst_available():
"""Determines whether pygstreamer is installed."""
try:
import gst
except ImportError:
return False
else:
return True
def _ca_available():
"""Determines whether CoreAudio is available (i.e., we're running on
Mac OS X).
"""
import ctypes.util
lib = ctypes.util.find_library('AudioToolbox')
return lib is not None
def _mad_available():
"""Determines whether the pymad bindings are available."""
try:
import mad
except ImportError:
return False
else:
return True
def audio_open(path):
"""Open an audio file using a library that is available on this
system.
"""
# Standard-library WAV and AIFF readers.
from . import rawread
try:
return rawread.RawAudioFile(path)
except DecodeError:
pass
# Core Audio.
if _ca_available():
from . import macca
try:
return macca.ExtAudioFile(path)
except DecodeError:
pass
# GStreamer.
if _gst_available():
from . import gstdec
try:
return gstdec.GstAudioFile(path)
except DecodeError:
pass
# MAD.
if _mad_available():
from . import maddec
try:
return maddec.MadAudioFile(path)
except DecodeError:
pass
# FFmpeg.
from . import ffdec
try:
return ffdec.FFmpegAudioFile(path)
except DecodeError:
pass
# All backends failed!
raise NoBackendError()
|