diff --git a/Ref_Audio_Selector/ref_audio_selector_webui.py b/Ref_Audio_Selector/ref_audio_selector_webui.py index 8cb1a57..954361a 100644 --- a/Ref_Audio_Selector/ref_audio_selector_webui.py +++ b/Ref_Audio_Selector/ref_audio_selector_webui.py @@ -310,9 +310,9 @@ def create_config(text_work_space_dir, text_template, text_sync_ref_audio_dir2): def whole_url(text_url, text_text, text_ref_path, text_ref_text, text_emotion): url_composer = audio_inference.URLComposer(text_url, text_emotion, text_text, text_ref_path, text_ref_text) if url_composer.is_emotion(): - text_whole_url = url_composer.build_url_with_emotion('测试内容', '情绪类型') + text_whole_url = url_composer.build_url_with_emotion('测试内容', '情绪类型', False) else: - text_whole_url = url_composer.build_url_with_ref('测试内容', '参考路径', '参考文本') + text_whole_url = url_composer.build_url_with_ref('测试内容', '参考路径', '参考文本', False) return text_whole_url @@ -409,8 +409,8 @@ with gr.Blocks() as app: gr.Markdown(value=i18n("3.3:根据相似度分析结果,重点检查最后几条是否存在复读等问题")) gr.Markdown(value=i18n("3.4:对结果按音频相似度排序,筛选低音质音频")) with gr.Row(): - text_base_audio_path = gr.Text(label=i18n("请输入基准音频"), value="text") - text_compare_audio_dir = gr.Text(label=i18n("请输入待比较的音频文件目录"), value="text") + text_base_audio_path = gr.Text(label=i18n("请输入基准音频"), value="") + text_compare_audio_dir = gr.Text(label=i18n("请输入待比较的音频文件目录"), value="") with gr.Row(): button_similarity_audio_output = gr.Button(i18n("输出相似度-参考音频到临时目录"), variant="primary") text_similarity_audio_output_info = gr.Text(label=i18n("输出结果"), value="", interactive=False) diff --git a/Ref_Audio_Selector/tool/audio_inference.py b/Ref_Audio_Selector/tool/audio_inference.py index f8bec4d..0df6b26 100644 --- a/Ref_Audio_Selector/tool/audio_inference.py +++ b/Ref_Audio_Selector/tool/audio_inference.py @@ -9,7 +9,7 @@ config = config_manager.get_config() class URLComposer: def __init__(self, base_url, emotion_param_name, text_param_name, ref_path_param_name, ref_text_param_name): - self.base_url = safe_encode_query_params(base_url) + self.base_url = base_url self.emotion_param_name = emotion_param_name self.text_param_name = text_param_name self.ref_path_param_name = ref_path_param_name @@ -28,35 +28,34 @@ class URLComposer: def is_emotion(self): return self.emotion_param_name is not None and self.emotion_param_name != '' - def build_url_with_emotion(self, text_value, emotion_value): + def build_url_with_emotion(self, text_value, emotion_value, need_url_encode=True): if not self.emotion_param_name: raise ValueError("Emotion parameter name is not set.") params = { - self.text_param_name: quote(text_value), - self.emotion_param_name: quote(emotion_value), + self.text_param_name: text_value, + self.emotion_param_name: emotion_value, } - return self._append_params_to_url(params) + return self._append_params_to_url(params, need_url_encode) - def build_url_with_ref(self, text_value, ref_path_value, ref_text_value): + def build_url_with_ref(self, text_value, ref_path_value, ref_text_value, need_url_encode=True): if self.emotion_param_name: raise ValueError("Cannot use reference parameters when emotion parameter is set.") params = { - self.text_param_name: quote(text_value), - self.ref_path_param_name: quote(ref_path_value), - self.ref_text_param_name: quote(ref_text_value), + self.text_param_name: text_value, + self.ref_path_param_name: ref_path_value, + self.ref_text_param_name: ref_text_value, } - return self._append_params_to_url(params) + return self._append_params_to_url(params, need_url_encode) - def _append_params_to_url(self, params: dict): + def _append_params_to_url(self, params, need_url_encode): url_with_params = self.base_url if params: query_params = '&'.join([f"{k}={v}" for k, v in params.items()]) url_with_params += '?' + query_params if '?' not in self.base_url else '&' + query_params - return url_with_params + return url_with_params if not need_url_encode else safe_encode_query_params(url_with_params) def safe_encode_query_params(original_url): - # 分析URL以获取查询字符串部分 parsed_url = urlparse(original_url) query_params = parse_qs(parsed_url.query)