bug修复

This commit is contained in:
Downupanddownup 2024-04-25 22:54:40 +08:00
parent c8be484c0e
commit 1da23aa259
8 changed files with 21 additions and 21 deletions

View File

@ -1,4 +1,4 @@
import Ref_Audio_Selector.config.config_manager as config_manager
import Ref_Audio_Selector.config_param.config_manager as config_manager
config = config_manager.get_config()

View File

@ -8,7 +8,7 @@ import Ref_Audio_Selector.tool.audio_inference as audio_inference
import Ref_Audio_Selector.tool.audio_config as audio_config
import Ref_Audio_Selector.tool.delete_inference_with_ref as delete_inference_with_ref
import Ref_Audio_Selector.common.common as common
import Ref_Audio_Selector.config.config_params as params
import Ref_Audio_Selector.config_param.config_params as params
from tools.i18n.i18n import I18nAuto
from config import python_exec, is_half
from tools import my_utils
@ -176,7 +176,7 @@ def model_inference(text_work_space_dir, text_role, text_model_inference_voice_d
traceback.print_exc()
text_model_inference_info = f"发生异常:{e}"
text_asr_audio_dir = ''
return i18n(text_model_inference_info), text_asr_audio_dir
return i18n(text_model_inference_info), text_asr_audio_dir, text_asr_audio_dir
# 对推理生成音频执行asr
@ -371,9 +371,9 @@ def save_work_dir(text_work_space_dir, text_role):
else:
role_dir = ''
for i in range(1, 101):
dir_name = os.path.join(text_work_space_dir, f"role_{i}")
role_dir = f"role_{i}"
dir_name = os.path.join(text_work_space_dir, role_dir)
if not os.path.isdir(dir_name):
role_dir = dir_name
break
rw_param.write_role(role_dir)
return role_dir
@ -398,7 +398,7 @@ with gr.Blocks() as app:
button_convert_from_list = gr.Button(i18n("开始生成待参考列表"), variant="primary")
text_convert_from_list_info = gr.Text(label=i18n("参考列表生成结果"), value="", interactive=False)
gr.Markdown(value=i18n("1.2:选择基准音频,执行相似度匹配,并分段随机抽样"))
text_sample_dir = gr.Text(label=i18n("参考音频抽样目录"), value="", interactive=False)
text_sample_dir = gr.Text(label=i18n("参考音频抽样目录"), value="", interactive=True)
button_convert_from_list.click(convert_from_list, [text_work_space_dir, text_role, text_list_input],
[text_convert_from_list_info, text_sample_dir])
with gr.Row():
@ -440,11 +440,7 @@ with gr.Blocks() as app:
text_model_inference_info = gr.Text(label=i18n("批量推理结果"), value="", interactive=False)
with gr.Accordion(label=i18n("第三步:进行参考音频效果校验与筛选"), open=False):
gr.Markdown(value=i18n("3.1启动asr获取推理音频文本"))
text_asr_audio_dir = gr.Text(label=i18n("待asr的音频所在目录"), value="", interactive=False)
button_model_inference.click(model_inference,
[text_work_space_dir, text_role, text_model_inference_voice_dir, text_url,
text_text, text_ref_path, text_ref_text, text_emotion,
text_test_content], [text_model_inference_info, text_asr_audio_dir])
text_asr_audio_dir = gr.Text(label=i18n("待asr的音频所在目录"), value="", interactive=True)
with gr.Row():
dropdown_asr_model = gr.Dropdown(
label=i18n("ASR 模型"),
@ -468,7 +464,7 @@ with gr.Blocks() as app:
button_asr = gr.Button(i18n("启动asr"), variant="primary")
text_asr_info = gr.Text(label=i18n("asr结果"), value="", interactive=False)
gr.Markdown(value=i18n("3.2:启动文本相似度分析"))
text_text_similarity_analysis_path = gr.Text(label=i18n("待分析的文件路径"), value="", interactive=False)
text_text_similarity_analysis_path = gr.Text(label=i18n("待分析的文件路径"), value="", interactive=True)
button_asr.click(asr, [text_work_space_dir, text_role, text_asr_audio_dir, dropdown_asr_model,
dropdown_asr_size, dropdown_asr_lang],
[text_asr_info, text_text_similarity_analysis_path])
@ -491,7 +487,7 @@ with gr.Blocks() as app:
text_compare_audio_dir], [text_similarity_audio_output_info])
with gr.Row():
text_sync_ref_audio_dir = gr.Text(label=i18n("参考音频路径"), value="", interactive=True)
text_sync_inference_audio_dir = gr.Text(label=i18n("被同步的推理音频路径"), value="", interactive=False)
text_sync_inference_audio_dir = gr.Text(label=i18n("被同步的推理音频路径"), value="", interactive=True)
with gr.Row():
button_sync_ref_audio = gr.Button(i18n("将参考音频的删除情况,同步到推理音频目录"), variant="primary")
text_sync_ref_info = gr.Text(label=i18n("同步结果"), value="", interactive=False)
@ -501,7 +497,7 @@ with gr.Blocks() as app:
gr.Markdown(value=i18n("4.1:编辑模板"))
default_template_path = params.default_template_path
default_template_content = common.read_file(default_template_path)
text_template_path = gr.Text(label=i18n("模板文件路径"), value=default_template_path, interactive=False)
text_template_path = gr.Text(label=i18n("模板文件路径"), value=default_template_path, interactive=True)
text_template = gr.Text(label=i18n("模板内容"), value=default_template_content, lines=10)
gr.Markdown(value=i18n("4.2:生成配置"))
text_sync_ref_audio_dir2 = gr.Text(label=i18n("参考音频路径"), value="", interactive=True)
@ -515,6 +511,10 @@ with gr.Blocks() as app:
text_subsection_num, text_sample_num, checkbox_similarity_output],
[text_sample_info, text_model_inference_voice_dir, text_sync_ref_audio_dir,
text_sync_ref_audio_dir2])
button_model_inference.click(model_inference,
[text_work_space_dir, text_role, text_model_inference_voice_dir, text_url,
text_text, text_ref_path, text_ref_text, text_emotion,
text_test_content], [text_model_inference_info, text_asr_audio_dir, text_sync_inference_audio_dir])
app.launch(
server_port=9423,

View File

@ -3,7 +3,7 @@
import argparse
import os
import traceback
import Ref_Audio_Selector.config.config_params as params
import Ref_Audio_Selector.config_param.config_params as params
from tqdm import tqdm
from funasr import AutoModel

View File

@ -1,7 +1,7 @@
import os
import requests
import itertools
import Ref_Audio_Selector.config.config_params as params
import Ref_Audio_Selector.config_param.config_params as params
from urllib.parse import urlparse, parse_qs, urlencode, urlunparse, quote

View File

@ -1,7 +1,7 @@
import os
import shutil
import Ref_Audio_Selector.common.common as common
import Ref_Audio_Selector.config.config_params as params
import Ref_Audio_Selector.config_param.config_params as params
def remove_matching_audio_files_in_text_dir(text_dir, emotions_list):
@ -11,7 +11,7 @@ def remove_matching_audio_files_in_text_dir(text_dir, emotions_list):
emotion_tag = emotion_dict['emotion']
wav_file_name = f"{emotion_tag}.wav"
file_path = os.path.join(root, wav_file_name)
if os.path.exists(file_path):
if not os.path.exists(file_path):
print(f"Deleting file: {file_path}")
try:
os.remove(file_path)
@ -38,7 +38,7 @@ def delete_emotion_subdirectories(emotion_dir, emotions_list):
folder_path = os.path.join(emotion_dir, emotion_folder)
# 检查emotion子目录是否存在
if os.path.isdir(folder_path):
if not os.path.isdir(folder_path):
print(f"Deleting directory: {folder_path}")
try:
# 使用shutil.rmtree删除整个子目录及其内容

View File

@ -3,7 +3,7 @@ import argparse
from collections import defaultdict
from operator import itemgetter
import Ref_Audio_Selector.tool.text_comparison.text_comparison as text_comparison
import Ref_Audio_Selector.config.config_params as params
import Ref_Audio_Selector.config_param.config_params as params
import Ref_Audio_Selector.common.common as common
@ -34,7 +34,7 @@ def parse_asr_file(file_path):
def calculate_similarity_and_append_to_list(input_list, boundary):
for item in input_list:
similarity_score = text_comparison.calculate_result(item['original_text'], item['asr_text'], boundary)
_, similarity_score = text_comparison.calculate_result(item['original_text'], item['asr_text'], boundary)
item['similarity_score'] = similarity_score
return input_list