old_contents: # -*- coding: utf-8 -*-
  """
  Created on Mon Nov 16 08:59:34 2020
  
  @author: wantysal
  """
  
  # Standard library imports
  import numpy as np
  import pyuff
  from scipy.io import wavfile
  from scipy.signal import resample
  
  
  
  def load(is_stationary, file, calib=1 ):
      """ Extract the signal and its time axis from .wav or .uff file,
      resample the signal to 48 kHz, and affects its sampling frequency 
      and time signal values.
      
      Parameters
      ----------
      is_stationary : boolean
          TRUE if the signal is stationary, FALSE if it is time-varying
      file : string
          string path to the signal file
      calib : float
          calibration factor for the signal to be in [pa]
  
      Outputs
      -------
      signal : numpy.array
          time signal values
      fs : integer
          sampling frequency        
      """
      
      # load the wav file content
      if file[-3:] == 'wav':
          fs, signal = wavfile.read(file) 
          
          # calibration factor for the signal to be in Pa
          if isinstance(signal[0], np.int16):
              signal = calib * signal / (2 ** 15 - 1)
          elif isinstance(signal[0], np.int32):
              signal = calib * signal / (2 ** 31 - 1)  
          
      # load the uff file content
      elif file[-3:] == 'uff':
          uff_file = pyuff.UFF(file)
          data = uff_file.read_sets()
          data.keys()
      
          #extract the signal values
          signal = data['data']
      
          # calculate the sampling frequency
          fs = int(1/data['abscissa_inc'])
      
      # resample to 48kHz to allow calculation
      if fs != 48000:
          signal = resample(signal, 48000*int(len(signal)/fs))
          fs = 48000
          print("Signal resampled to 48 kHz to allow calculation.")
      
          
      return signal, fs
new_contents: # -*- coding: utf-8 -*-
  """
  Created on Mon Nov 16 08:59:34 2020
  
  @author: wantysal
  """
  
  # Standard library imports
  import numpy as np
  import pyuff
  from scipy.io import wavfile
  from scipy.signal import resample
  
  
  
  def load(is_stationary, file, calib=1 ):
      """ Extract the signal and its time axis from .wav or .uff file,
      resample the signal to 48 kHz, and affects its sampling frequency 
      and time signal values.
      
      Parameters
      ----------
      is_stationary : boolean
          TRUE if the signal is stationary, FALSE if it is time-varying
      file : string
          string path to the signal file
      calib : float
          calibration factor for the signal to be in [pa]
  
      Outputs
      -------
      signal : numpy.array
          time signal values
      fs : integer
          sampling frequency        
      """
      
      # load the wav file content    
      if file[-3:] == 'wav':
          fs, signal = wavfile.read(file) 
          
          # calibration factor for the signal to be in Pa
          if isinstance(signal[0], np.int16):
              signal = calib * signal / (2 ** 15 - 1)
          elif isinstance(signal[0], np.int32):
              signal = calib * signal / (2 ** 31 - 1)  
          
      # load the uff file content
      elif file[-3:] == 'uff':
          uff_file = pyuff.UFF(file)
          data = uff_file.read_sets()
          data.keys()
      
          #extract the signal values
          signal = data['data']
      
          # calculate the sampling frequency
          fs = int(1/data['abscissa_inc'])
          
      else:
          raise ValueError(
              """ERROR: only .wav or .uff file are supported"""
          )
      
      # resample to 48kHz to allow calculation
      if fs != 48000:
          signal = resample(signal, 48000*int(len(signal)/fs))
          fs = 48000
          print("Signal resampled to 48 kHz to allow calculation.")
      
          
      return signal, fs
subject: raise value error is file is not a .wav or .uff