dd some defensive code if audio file cannot be read - issue #42
This commit is contained in:
Родитель
2bc78fcb61
Коммит
5c0d72e4db
|
@ -41,6 +41,7 @@ def audioread(path, norm=False, start=0, stop=None, target_level=-25):
|
|||
audio, sample_rate = sf.read(path, start=start, stop=stop)
|
||||
except RuntimeError: # fix for sph pcm-embedded shortened v2
|
||||
print('WARNING: Audio type not supported')
|
||||
return (None, None)
|
||||
|
||||
if len(audio.shape) == 1: # mono
|
||||
if norm:
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
# speech sourcefile once, as it does not randomly sample from these files
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import argparse
|
||||
import ast
|
||||
|
@ -80,6 +81,9 @@ def build_audio(is_clean, params, index, audio_samples_length=-1):
|
|||
|
||||
idx = (idx + 1) % np.size(source_files)
|
||||
input_audio, fs_input = audioread(source_files[idx])
|
||||
if input_audio is None:
|
||||
sys.stderr.write("WARNING: Cannot read file: %s\n" % source_files[idx])
|
||||
continue
|
||||
if fs_input != fs_output:
|
||||
input_audio = librosa.resample(input_audio, fs_input, fs_output)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче