添加音频预采样开关

This commit is contained in:
Downupanddownup 2024-04-26 16:27:21 +08:00
parent 64cc2fd9d1
commit 9fe20c14d6
3 changed files with 8 additions and 1 deletions

View File

@ -21,6 +21,8 @@ time_log_print_dir = Ref_Audio_Selector/log/performance
list_to_convert_reference_audio_dir = refer_audio_all
# 音频相似度目录
audio_similarity_dir = similarity
# 是否开启基准音频预采样 true false
enable_pre_sample = true
[Inference]
# 默认测试文本位置

View File

@ -23,6 +23,8 @@ time_log_print_dir = config.get_log('time_log_print_dir')
list_to_convert_reference_audio_dir = config.get_audio_sample('list_to_convert_reference_audio_dir')
# 音频相似度目录
audio_similarity_dir = config.get_audio_sample('audio_similarity_dir')
# 是否开启基准音频预采样 true false
enable_pre_sample = config.get_audio_sample('enable_pre_sample')
# [Inference]
# 默认测试文本位置

View File

@ -28,9 +28,12 @@ def compare_audio_and_generate_report(reference_audio_path, comparison_dir_path,
# 改用torchaudio.transforms.Resample进行重采样如果在非windows环境下没有更改依赖包的采样方法的话
# 使用这段代码进行预采样会出现因为采样方法不同,而导致的模型相似度计算不准确的问题
# 当然如果在windows下使用了其他的采样方法也会出现不准确的问题
if params.enable_pre_sample == 'true':
reference_audio_16k = ensure_16k_wav(reference_audio_path)
else:
reference_audio_16k = reference_audio_path
else:
reference_audio_16k = reference_audio_path
# Step 2: 用参考音频依次比较音频目录下的每个音频,获取相似度分数及对应路径
all_count = len(comparison_audio_paths)