aboutsummaryrefslogtreecommitdiffstats
path: root/extlib/freesound/audioprocessing.py
diff options
context:
space:
mode:
authorBen Sturmfels <ben@sturm.com.au>2020-04-01 16:52:05 +1100
committerBen Sturmfels <ben@sturm.com.au>2020-04-01 16:52:05 +1100
commit1038aea822fdc8a84745bd44cc96ed97d66bbc28 (patch)
tree4f684a61a72f9b5b612e864ee1e455f3651381eb /extlib/freesound/audioprocessing.py
parentad3a0aea833a26735d1d2986f427e9f286dbac21 (diff)
downloadmediagoblin-1038aea822fdc8a84745bd44cc96ed97d66bbc28.tar.lz
mediagoblin-1038aea822fdc8a84745bd44cc96ed97d66bbc28.tar.xz
mediagoblin-1038aea822fdc8a84745bd44cc96ed97d66bbc28.zip
Fix audio thumbnailing once and for all.
This change adds a Python 3-specific audio thumbnailer that side-steps the bundled Python 2-only `audioprocessing` module. Instead of an audio spectrogram, Python 3 users will get a static image. This also allows me to remove my ineffective customisations to `audioprocessing`, returning it to the upstream version as should always be the case for vendored code in "extlib".
Diffstat (limited to 'extlib/freesound/audioprocessing.py')
-rw-r--r--extlib/freesound/audioprocessing.py27
1 files changed, 1 insertions, 26 deletions
diff --git a/extlib/freesound/audioprocessing.py b/extlib/freesound/audioprocessing.py
index b9a96a97..b002ff8a 100644
--- a/extlib/freesound/audioprocessing.py
+++ b/extlib/freesound/audioprocessing.py
@@ -43,32 +43,7 @@ def get_sound_type(input_filename):
try:
import scikits.audiolab as audiolab
except ImportError:
- print("WARNING: audiolab is not installed so wav2png will not work")
-
- # Hack to prevent errors when uploading audio files. The issue is that
- # scikits.audiolab does not support Python 3. By replacing it with a mock
- # implementation here, we can accept audio files, but we won't get the nice
- # waveform image.
- import six
- if six.PY3:
- class MockSndfile(object):
- def __init__(self, *args, **kwargs):
- self.nframes = 0
- self.channels = 1
- self.samplerate = 44100
-
- def read_frames(self, *args):
- return []
-
- def seek(self, *args):
- return
-
- def close(self):
- return
- import unittest.mock as mock
- audiolab = mock.Mock()
- audiolab.Sndfile = MockSndfile
-
+ print "WARNING: audiolab is not installed so wav2png will not work"
import subprocess
class AudioProcessingException(Exception):