Spaces:
Sleeping
Sleeping
app revise test
Browse files
app.py
CHANGED
|
@@ -2,8 +2,16 @@ import gradio as gr
|
|
| 2 |
#from inference import InferencePipeline
|
| 3 |
|
| 4 |
#i = InferencePipeline()
|
|
|
|
| 5 |
|
| 6 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
"""
|
| 8 |
Wrapper function to handle Gradio's audio input and pass the file path to the voice conversion function.
|
| 9 |
Gradio passes audio data as a tuple: (temp file path, sample rate).
|
|
@@ -17,14 +25,32 @@ def gradio_voice_conversion(audio_file_path):
|
|
| 17 |
return random_wav
|
| 18 |
|
| 19 |
# Define your Gradio interface
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
| 30 |
demo.launch()
|
|
|
|
| 2 |
#from inference import InferencePipeline
|
| 3 |
|
| 4 |
#i = InferencePipeline()
|
| 5 |
+
# device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 6 |
|
| 7 |
+
# def convert_audio_to_wav(file_path):
|
| 8 |
+
# """Convert any supported format (mp3, etc.) to wav using librosa"""
|
| 9 |
+
# output_path = "temp_input.wav"
|
| 10 |
+
# audio, sr = librosa.load(file_path, sr=None) # 加载音频文件
|
| 11 |
+
# librosa.output.write_wav(output_path, audio, sr) # 转换并保存为 WAV 格式
|
| 12 |
+
# return output_path
|
| 13 |
+
|
| 14 |
+
def gradio_TSE(audio_file_path):
|
| 15 |
"""
|
| 16 |
Wrapper function to handle Gradio's audio input and pass the file path to the voice conversion function.
|
| 17 |
Gradio passes audio data as a tuple: (temp file path, sample rate).
|
|
|
|
| 25 |
return random_wav
|
| 26 |
|
| 27 |
# Define your Gradio interface
|
| 28 |
+
with gr.Blocks() as demo:
|
| 29 |
+
gr.Markdown("## Target Speaker Extraction Demo")
|
| 30 |
+
gr.Markdown(
|
| 31 |
+
"This demo isolates the speech signal of a target speaker from a mixture of multiple speakers, "
|
| 32 |
+
"with or without noises and reverberations."
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
# input
|
| 36 |
+
with gr.Row():
|
| 37 |
+
input_audio = gr.Audio(label="Upload or record your input (mixture) audio", type="filepath")
|
| 38 |
+
enroll_audio = gr.Audio(label="Upload your enroll (target speaker) audio", type="filepath")
|
| 39 |
+
|
| 40 |
+
# output
|
| 41 |
+
with gr.Row():
|
| 42 |
+
noisy_audio_output = gr.Audio(label="Noisy Audio (Input with Noise)", type="filepath")
|
| 43 |
+
extracted_audio_output = gr.Audio(label="Extracted Target Speaker Audio", type="filepath")
|
| 44 |
+
|
| 45 |
+
# deal
|
| 46 |
+
convert_button = gr.Button("Process Audio")
|
| 47 |
+
|
| 48 |
+
# event
|
| 49 |
+
convert_button.click(
|
| 50 |
+
fn=gradio_TSE,
|
| 51 |
+
inputs=[input_audio, enroll_audio],
|
| 52 |
+
outputs=[noisy_audio_output, extracted_audio_output]
|
| 53 |
+
)
|
| 54 |
|
| 55 |
if __name__ == "__main__":
|
| 56 |
demo.launch()
|