I am working on reading audio files from three directories and calculate a PESQ score for these signals, sometimes this score cannot be calculated for some signals and give (Processing error!) how can I skip this error or signals and continue run the code.
My trial to add try and except if the result is not float number, pass but also not working
from pesq import pesq
from pystoi.stoi import stoi
import scipy.io.wavfile as wav
import numpy as np
import glob
for x, filename in enumerate(glob.glob('E:\eyFSC/**/*.wav')):
print (x, filename)
sr, mix = wav.read(filename) ##Why do you need this one btw, you never use it
enhname=filename.replace('eyFSC','enFSC')
sr, enh = wav.read(enhname)
enhwname=filename.replace('eyFSC','enwFSC')
sr,enhw= wav.read(enhwname)
oriname=filename.replace('eyFSC','cFSC')
sr,ori= wav.read(oriname)
try:
if type((pesq(16000, enh, mix, 'nb')) and (pesq(16000, enhw, mix, 'nb')) and (pesq(16000, ori, mix, 'nb'))) != float:
print('Stop')
except:
pass
print('Scores are finished')
Here is the problem. The code stops after signal number 578 and doesn't complete.
577 E:\eyFSC\2ojo7YRL7Gck83Z3\94d4ddc0-45e0-11e9-81ce-69b74fd7e64e.wav
578 E:\eyFSC\2ojo7YRL7Gck83Z3\96202d00-45e1-11e9-81ce-69b74fd7e64e.wav
Processing error!