Webui #1
+31
-3
@@ -151,11 +151,35 @@ def _history_label(history: list) -> str:
|
|||||||
return f"Edit history: {len(history) - 1} edit(s) applied on top of the original reference."
|
return f"Edit history: {len(history) - 1} edit(s) applied on top of the original reference."
|
||||||
|
|
||||||
|
|
||||||
def apply_edit(current_ref: str, history: list, emotion: str, pitch: str, speed: str, custom_instruction: str):
|
ENHANCE_INSTRUCTIONS = {
|
||||||
|
"none": None,
|
||||||
|
"General (denoise + dereverb)": (
|
||||||
|
"Preserve all speakers, remove noise and reverberation, and output "
|
||||||
|
"clean speech of the same length."
|
||||||
|
),
|
||||||
|
"Telephone/call recording": (
|
||||||
|
"Repair the telephone effect and restore natural, clear speech."
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def apply_edit(
|
||||||
|
current_ref: str,
|
||||||
|
history: list,
|
||||||
|
enhance: str,
|
||||||
|
emotion: str,
|
||||||
|
pitch: str,
|
||||||
|
speed: str,
|
||||||
|
custom_instruction: str,
|
||||||
|
):
|
||||||
if not current_ref:
|
if not current_ref:
|
||||||
raise gr.Error("Set a voice reference first (upload, strip with Demucs, or use a previous edit).")
|
raise gr.Error("Set a voice reference first (upload, strip with Demucs, or use a previous edit).")
|
||||||
|
|
||||||
instructions = []
|
instructions = []
|
||||||
|
# Enhancement goes first when picked - clean the recording up before any
|
||||||
|
# character/accent editing, not after (garbage in, garbage timbre-edited).
|
||||||
|
if enhance and ENHANCE_INSTRUCTIONS.get(enhance):
|
||||||
|
instructions.append(ENHANCE_INSTRUCTIONS[enhance])
|
||||||
if emotion and emotion != "none":
|
if emotion and emotion != "none":
|
||||||
instructions.append(f"Change the emotion to {emotion}.")
|
instructions.append(f"Change the emotion to {emotion}.")
|
||||||
if pitch and pitch != "none":
|
if pitch and pitch != "none":
|
||||||
@@ -167,7 +191,7 @@ def apply_edit(current_ref: str, history: list, emotion: str, pitch: str, speed:
|
|||||||
instructions.append(custom_instruction.strip())
|
instructions.append(custom_instruction.strip())
|
||||||
|
|
||||||
if not instructions:
|
if not instructions:
|
||||||
raise gr.Error("Pick at least one edit (emotion / pitch / speed / custom instruction).")
|
raise gr.Error("Pick at least one edit (enhance / emotion / pitch / speed / custom instruction).")
|
||||||
|
|
||||||
_free_comfyui_memory()
|
_free_comfyui_memory()
|
||||||
ref = current_ref
|
ref = current_ref
|
||||||
@@ -270,6 +294,10 @@ with gr.Blocks(title="Audio-demo pipeline studio") as demo:
|
|||||||
gr.Markdown("## 2. Voice editor (AuK)")
|
gr.Markdown("## 2. Voice editor (AuK)")
|
||||||
current_ref_audio = gr.Audio(label="Current reference", type="filepath", interactive=False)
|
current_ref_audio = gr.Audio(label="Current reference", type="filepath", interactive=False)
|
||||||
history_label = gr.Markdown("No reference set yet.")
|
history_label = gr.Markdown("No reference set yet.")
|
||||||
|
enhance_dd = gr.Dropdown(
|
||||||
|
list(ENHANCE_INSTRUCTIONS.keys()), value="none",
|
||||||
|
label="Enhance (denoise/dereverb/restore) - runs first, before character edits",
|
||||||
|
)
|
||||||
emotion_dd = gr.Dropdown(["none"] + EMOTIONS, value="none", label="Emotion")
|
emotion_dd = gr.Dropdown(["none"] + EMOTIONS, value="none", label="Emotion")
|
||||||
pitch_dd = gr.Dropdown(["none"] + PITCH_OPTIONS, value="none", label="Pitch (semitones)")
|
pitch_dd = gr.Dropdown(["none"] + PITCH_OPTIONS, value="none", label="Pitch (semitones)")
|
||||||
speed_dd = gr.Dropdown(["none"] + SPEED_OPTIONS, value="none", label="Speed")
|
speed_dd = gr.Dropdown(["none"] + SPEED_OPTIONS, value="none", label="Speed")
|
||||||
@@ -309,7 +337,7 @@ with gr.Blocks(title="Audio-demo pipeline studio") as demo:
|
|||||||
)
|
)
|
||||||
apply_btn.click(
|
apply_btn.click(
|
||||||
apply_edit,
|
apply_edit,
|
||||||
inputs=[current_ref_audio, history_state, emotion_dd, pitch_dd, speed_dd, custom_instruction],
|
inputs=[current_ref_audio, history_state, enhance_dd, emotion_dd, pitch_dd, speed_dd, custom_instruction],
|
||||||
outputs=[current_ref_audio, history_state, history_label],
|
outputs=[current_ref_audio, history_state, history_label],
|
||||||
)
|
)
|
||||||
undo_btn.click(
|
undo_btn.click(
|
||||||
|
|||||||
Reference in new issue
Block a user