Ticket #5467: issue_5467_temp_fix.patch

File issue_5467_temp_fix.patch, 1.2 KB (added by Ben Sturmfels, 8 years ago)

Temporary fix to mock out missing audiolab

  • extlib/freesound/audioprocessing.py

    From 57df92d1a0866f9335fe55597d1359ac60cc0711 Mon Sep 17 00:00:00 2001
    From: Ben Sturmfels <ben@sturm.com.au>
    Date: Fri, 23 Sep 2016 17:14:42 +1000
    Subject: [PATCH] Temporary fix to allow audio processing to proceed without
     audiolab.
    
    ---
     extlib/freesound/audioprocessing.py | 17 +++++++++++++++++
     1 file changed, 17 insertions(+)
    
    diff --git a/extlib/freesound/audioprocessing.py b/extlib/freesound/audioprocessing.py
    index 7ef8d5d..331f19a 100644
    a b try:  
    4444    import scikits.audiolab as audiolab
    4545except ImportError:
    4646    print("WARNING: audiolab is not installed so wav2png will not work")
     47    class MockSndfile(object):
     48        def __init__(self, *args, **kwargs):
     49            self.nframes = 0
     50            self.channels = 1
     51            self.samplerate = 44100
     52
     53        def read_frames(self, *args):
     54            return []
     55
     56        def seek(self, *args):
     57            return
     58
     59        def close(self):
     60            return
     61    import unittest.mock as mock
     62    audiolab = mock.Mock()
     63    audiolab.Sndfile = MockSndfile
    4764import subprocess
    4865
    4966class AudioProcessingException(Exception):