Skip to content

Commit

Permalink
Merge pull request #747 from ShiromiyaG/fix-speaker-id
Browse files Browse the repository at this point in the history
Fix a few things
  • Loading branch information
blaisewf authored Sep 28, 2024
2 parents a0cc410 + c5e6c0d commit 636f473
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions assets/i18n/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,7 @@
"Move files to custom embedder folder": "Move files to custom embedder folder",
"model information": "model information",
"Model Creator": "Model Creator",
"Name of the model creator. (Default: Unknown)": "Name of the model creator. (Default: Unknown)"
}
"Name of the model creator. (Default: Unknown)": "Name of the model creator. (Default: Unknown)",
"Speaker ID": "Speaker ID",
"Select the speaker ID to use for the conversion.": "Select the speaker ID to use for the conversion."
}
12 changes: 9 additions & 3 deletions tabs/inference/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ def output_path_fn(input_audio_path):
return output_path


def change_choices():
def change_choices(model):
if model:
speakers = get_speakers_id(model)
else:
speakers = 0
names = [
os.path.join(root, file)
for root, _, files in os.walk(model_root_relative, topdown=False)
Expand Down Expand Up @@ -205,6 +209,7 @@ def change_choices():
{"choices": sorted(names), "__type__": "update"},
{"choices": sorted(indexes_list), "__type__": "update"},
{"choices": sorted(audio_paths), "__type__": "update"},
{"choices": sorted(speakers), "__type__": "update"},
)


Expand Down Expand Up @@ -304,7 +309,7 @@ def get_speakers_id(model):
if model:
model_data = torch.load(model, map_location="cpu")
speakers_id = model_data.get("speakers_id", 0)
return list(range(speakers_id + 1))
return list(range(speakers_id))


# Inference tab
Expand Down Expand Up @@ -1928,11 +1933,12 @@ def delay_visible(checkbox):
)
refresh_button.click(
fn=change_choices,
inputs=[],
inputs=[model_file],
outputs=[
model_file,
index_file,
audio,
sid,
],
)
audio.change(
Expand Down

0 comments on commit 636f473

Please sign in to comment.