Skip to content

Commit

Permalink
feat(gui): configurable output file (voicepaw#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
visidyn committed Apr 22, 2023
1 parent cbd3896 commit 82bc710
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/so_vits_svc_fork/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ def delete_preset(name: str) -> dict:
return load_presets()


def get_output_path(input_path: Path) -> Path:
output_path = (
input_path.parent / f"{input_path.stem}.out{input_path.suffix}"
)
file_num = 1
while output_path.exists():
output_path = (
input_path.parent / f"{input_path.stem}.out_{file_num}{input_path.suffix}"
)
return output_path


def get_devices(
update: bool = True,
) -> tuple[list[str], list[str], list[int], list[int]]:
Expand Down Expand Up @@ -255,10 +267,19 @@ def main():
[
sg.Text("Input audio path"),
sg.Push(),
sg.InputText(key="input_path"),
sg.InputText(key="input_path", enable_events=True),
sg.FileBrowse(initial_folder=".", key="input_path_browse"),
sg.Button("Play", key="play_input"),
],
[
sg.Text("Output audio path"),
sg.Push(),
sg.InputText(key="output_path"),
sg.FileSaveAs(
initial_folder=".",
key="output_path_browse",
file_types=(("WAV", ".wav"), ("MP3", ".mp3"))),
],
[sg.Checkbox(key="auto_play", text="Auto play", default=True)],
],
"Realtime": [
Expand Down Expand Up @@ -543,11 +564,13 @@ def apply_preset(name: str) -> None:
update_devices()
elif event == "config_path":
update_speaker()
elif event == "input_path":
window.Element("output_path").Update(
str(get_output_path(Path(values["input_path"]))))
elif event == "infer":
input_path = Path(values["input_path"])
output_path = (
input_path.parent / f"{input_path.stem}.out{input_path.suffix}"
)
output_path = Path(values["output_path"])

if not input_path.exists() or not input_path.is_file():
LOG.warning(f"Input path {input_path} does not exist.")
continue
Expand Down

0 comments on commit 82bc710

Please sign in to comment.