mirror of
https://github.com/svc-develop-team/so-vits-svc.git
synced 2025-01-08 11:57:43 +08:00
feat(preprocess): add error context for wave error
This commit is contained in:
parent
a5dac31f43
commit
a936231e9a
@ -13,14 +13,17 @@ import diffusion.logger.utils as du
|
||||
pattern = re.compile(r'^[\.a-zA-Z0-9_\/]+$')
|
||||
|
||||
def get_wav_duration(file_path):
|
||||
with wave.open(file_path, 'rb') as wav_file:
|
||||
# 获取音频帧数
|
||||
n_frames = wav_file.getnframes()
|
||||
# 获取采样率
|
||||
framerate = wav_file.getframerate()
|
||||
# 计算时长(秒)
|
||||
duration = n_frames / float(framerate)
|
||||
return duration
|
||||
try:
|
||||
with wave.open(file_path, 'rb') as wav_file:
|
||||
# 获取音频帧数
|
||||
n_frames = wav_file.getnframes()
|
||||
# 获取采样率
|
||||
framerate = wav_file.getframerate()
|
||||
# 计算时长(秒)
|
||||
return n_frames / float(framerate)
|
||||
except Exception as e:
|
||||
logger.error(f"Reading {file_path}")
|
||||
raise e
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
|
Loading…
Reference in New Issue
Block a user