Spaces:
Sleeping
Sleeping
cleanup instructions
Browse files
app.py
CHANGED
|
@@ -23,7 +23,7 @@ system = init(ckpt_path, batch_size=BATCH_SIZE, use_cuda=USE_CUDA)
|
|
| 23 |
def inference_audio(audio_path: str, query_audio_path: str):
|
| 24 |
"""使用音频作为query进行推理"""
|
| 25 |
temp_dir = tempfile.gettempdir()
|
| 26 |
-
output_filename = os.path.basename(audio_path).replace('.wav', '
|
| 27 |
output_path = os.path.join(temp_dir, output_filename)
|
| 28 |
inference_file(system, audio_path, output_path, query_audio_path) # 第二个参数改为query_path
|
| 29 |
return output_path
|
|
@@ -31,7 +31,7 @@ def inference_audio(audio_path: str, query_audio_path: str):
|
|
| 31 |
def inference_text(audio_path: str, query_text: str):
|
| 32 |
"""使用文本作为query进行推理"""
|
| 33 |
temp_dir = tempfile.gettempdir()
|
| 34 |
-
output_filename = os.path.basename(audio_path).replace('.wav', '
|
| 35 |
output_path = os.path.join(temp_dir, output_filename)
|
| 36 |
inference_file_text(system, audio_path, output_path, query_text) # 使用文本推理函数
|
| 37 |
return output_path
|
|
@@ -55,13 +55,11 @@ def inference(audio_path: str, query_input, query_type: str):
|
|
| 55 |
with gr.Blocks() as demo:
|
| 56 |
gr.Markdown(
|
| 57 |
"""
|
| 58 |
-
#
|
| 59 |
**How to use:**
|
| 60 |
1. 上传原音频文件
|
| 61 |
2. 选择query类型(音频或文字)并提供query内容
|
| 62 |
-
3. 点击 **
|
| 63 |
-
|
| 64 |
-
**Sample audio:** 点击下面的样例自动填充输入
|
| 65 |
"""
|
| 66 |
)
|
| 67 |
|
|
@@ -96,12 +94,12 @@ with gr.Blocks() as demo:
|
|
| 96 |
visible=False
|
| 97 |
)
|
| 98 |
|
| 99 |
-
|
| 100 |
|
| 101 |
with gr.Column():
|
| 102 |
# 输出音频
|
| 103 |
out_audio = gr.Audio(
|
| 104 |
-
label="
|
| 105 |
show_download_button=True
|
| 106 |
)
|
| 107 |
|
|
@@ -126,7 +124,7 @@ with gr.Blocks() as demo:
|
|
| 126 |
outputs=[inp_query_audio, inp_query_text]
|
| 127 |
)
|
| 128 |
|
| 129 |
-
#
|
| 130 |
def process_inference(audio_path, query_type, query_audio, query_text):
|
| 131 |
"""处理推理请求"""
|
| 132 |
# 根据query类型获取相应的query输入
|
|
@@ -136,7 +134,7 @@ with gr.Blocks() as demo:
|
|
| 136 |
result, status_msg = inference(audio_path, query_input, query_type)
|
| 137 |
return result, status_msg
|
| 138 |
|
| 139 |
-
|
| 140 |
process_inference,
|
| 141 |
inputs=[inp_audio, query_type, inp_query_audio, inp_query_text],
|
| 142 |
outputs=[out_audio, status]
|
|
|
|
| 23 |
def inference_audio(audio_path: str, query_audio_path: str):
|
| 24 |
"""使用音频作为query进行推理"""
|
| 25 |
temp_dir = tempfile.gettempdir()
|
| 26 |
+
output_filename = os.path.basename(audio_path).replace('.wav', '_inference.wav')
|
| 27 |
output_path = os.path.join(temp_dir, output_filename)
|
| 28 |
inference_file(system, audio_path, output_path, query_audio_path) # 第二个参数改为query_path
|
| 29 |
return output_path
|
|
|
|
| 31 |
def inference_text(audio_path: str, query_text: str):
|
| 32 |
"""使用文本作为query进行推理"""
|
| 33 |
temp_dir = tempfile.gettempdir()
|
| 34 |
+
output_filename = os.path.basename(audio_path).replace('.wav', '_inference.wav')
|
| 35 |
output_path = os.path.join(temp_dir, output_filename)
|
| 36 |
inference_file_text(system, audio_path, output_path, query_text) # 使用文本推理函数
|
| 37 |
return output_path
|
|
|
|
| 55 |
with gr.Blocks() as demo:
|
| 56 |
gr.Markdown(
|
| 57 |
"""
|
| 58 |
+
# 🎵 Language-Audio Banquet (Demo)
|
| 59 |
**How to use:**
|
| 60 |
1. 上传原音频文件
|
| 61 |
2. 选择query类型(音频或文字)并提供query内容
|
| 62 |
+
3. 点击 **Inference** → 收听并下载结果
|
|
|
|
|
|
|
| 63 |
"""
|
| 64 |
)
|
| 65 |
|
|
|
|
| 94 |
visible=False
|
| 95 |
)
|
| 96 |
|
| 97 |
+
inference_btn = gr.Button("Inference", variant="primary")
|
| 98 |
|
| 99 |
with gr.Column():
|
| 100 |
# 输出音频
|
| 101 |
out_audio = gr.Audio(
|
| 102 |
+
label="分离后的音频输出",
|
| 103 |
show_download_button=True
|
| 104 |
)
|
| 105 |
|
|
|
|
| 124 |
outputs=[inp_query_audio, inp_query_text]
|
| 125 |
)
|
| 126 |
|
| 127 |
+
# 按钮点击事件
|
| 128 |
def process_inference(audio_path, query_type, query_audio, query_text):
|
| 129 |
"""处理推理请求"""
|
| 130 |
# 根据query类型获取相应的query输入
|
|
|
|
| 134 |
result, status_msg = inference(audio_path, query_input, query_type)
|
| 135 |
return result, status_msg
|
| 136 |
|
| 137 |
+
inference_btn.click(
|
| 138 |
process_inference,
|
| 139 |
inputs=[inp_audio, query_type, inp_query_audio, inp_query_text],
|
| 140 |
outputs=[out_audio, status]
|