def load_generic_audio(directory, sample_rate):
 files = find_files(directory)
 id_reg_exp = re.compile(FILE_PATTERN)
 print 'files length: {}'.format(len(files))
 randomized_files = randomize_files(files)
 for filename in randomized_files:
  ids = id_reg_exp.findall(filename)
  if (ids is None):
   category_id = None
  else:
   category_id = int(ids[0][0])
  (audio, _) = librosa.load(filename, sr=sample_rate, mono=True)
  audio = audio.reshape((-1), 1)
  (yield (audio, filename, category_id))

def load_generic_audio ( directory , sample_rate ) : files = find_files ( directory ) id_reg_exp = re . compile ( FILE_PATTERN ) print 'files length: {}' . format ( len ( files ) ) randomized_files = randomize_files ( files ) for filename in randomized_files : ids = id_reg_exp . findall ( filename ) if ( ids is None ) : category_id = None else : category_id = int ( ids [ 0 ] [ 0 ] ) ( audio , _ ) = librosa . load ( filename , sr = sample_rate , mono = True ) audio = audio . reshape ( ( - 1 ) , 1 ) ( yield ( audio , filename , category_id ) )
generator that yields audio waveforms from the directory .