oItsMineZ commited on
Commit
aaa6efa
·
verified ·
1 Parent(s): f6cf01c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +112 -104
app.py CHANGED
@@ -501,7 +501,6 @@ from gtts import gTTS
501
  import edge_tts
502
  import asyncio
503
 
504
-
505
  def change_choices_fix():
506
  audio_paths=[]
507
  for filename in os.listdir("./audios"):
@@ -515,7 +514,6 @@ def change_choices_fix():
515
  most_recent_audio = max(audio_paths, key=os.path.getctime)
516
  return {"choices": sorted(audio_paths), "value": most_recent_audio, "__type__": "update"}
517
 
518
-
519
  def custom_voice(
520
  _values, # filter indices
521
  audio_files, # all audio files
@@ -737,7 +735,7 @@ def GradioSetup(UTheme=gr.themes.Soft()):
737
  label="Advanced Settings",
738
  interactive=True,
739
  )
740
-
741
  # Advanced settings container
742
  with gr.Column(visible=False) as advanced_settings: # Initially hidden
743
  with gr.Row(label = "Advanced Settings", open = False):
@@ -984,20 +982,22 @@ def GradioSetup(UTheme=gr.themes.Soft()):
984
  ],
985
  [vc_output1, vc_output2],
986
  )
987
-
988
-
989
- with gr.Group(visible=False): # Markdown explanation of batch inference
990
- with gr.Row(visible=False):
991
- with gr.Column(visible=False):
 
 
992
  vc_transform1 = gr.Number(
993
- label="Transpose (integer, number of semitones, raise by an octave: 12, lower by an octave: -12):", value=0, visible=False
994
  )
995
- opt_input = gr.Textbox(label="Specify output folder:", value="opt, visible=False")
996
- with gr.Column(visible=False):
997
  file_index4 = gr.Dropdown(
998
- label="Auto-detect index path and select from the dropdown:",
999
  choices=get_indexes(),
1000
- value=def_index,
1001
  interactive=True,
1002
  )
1003
  sid0.select(fn=match_index, inputs=[sid0], outputs=[file_index2, file_index4])
@@ -1010,116 +1010,121 @@ def GradioSetup(UTheme=gr.themes.Soft()):
1010
  index_rate2 = gr.Slider(
1011
  minimum=0,
1012
  maximum=1,
1013
- label="Search feature ratio:",
1014
  value=0.75,
1015
  interactive=True,
1016
  )
1017
- with gr.Row(visible=False):
1018
  dir_input = gr.Textbox(
1019
- label="Enter the path of the audio folder to be processed (copy it from the address bar of the file manager):",
1020
  value=os.path.join(now_dir, "audios"),
1021
  )
1022
  inputs = gr.File(
1023
- file_count="multiple", label="You can also input audio files in batches. Choose one of the two options. Priority is given to reading from the folder.", visible=False
1024
  )
1025
 
1026
- with gr.Row(visible=False):
1027
- with gr.Column(visible=False):
1028
  # Create a checkbox for advanced batch settings
1029
  advanced_settings_batch_checkbox = gr.Checkbox(
1030
  value=False,
1031
- label="Advanced Settings",
1032
  interactive=True,
1033
  )
1034
-
1035
- # Advanced batch settings container
1036
- with gr.Row(visible=False) as advanced_settings_batch: # Initially hidden
1037
- with gr.Row(label = "Advanced Settings", open = False):
1038
- with gr.Column():
1039
- file_index3 = gr.Textbox(
1040
- label="Feature search database file path:",
1041
- value="",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1042
  interactive=True,
1043
  )
1044
-
1045
- f0method1 = gr.Radio(
1046
- label="Select the pitch extraction algorithm:",
1047
- choices=["pm", "harvest", "crepe", "rmvpe"],
1048
- value="rmvpe",
1049
- interactive=True,
1050
- )
1051
- f0_autotune = gr.Checkbox(
1052
- label="Enable autotune",
1053
- interactive=True,
1054
- )
1055
- filter_radius1 = gr.Slider(
1056
- minimum=0,
1057
- maximum=7,
1058
- label="If >=3: apply median filtering to the harvested pitch results. The value represents the filter radius and can reduce breathiness.",
1059
- value=3,
1060
- step=1,
1061
- interactive=True,
1062
- )
1063
 
1064
- with gr.Row(visible=False):
1065
- format1 = gr.Radio(
1066
- label="Export file format",
1067
- choices=["wav", "flac", "mp3", "m4a"],
1068
- value="wav",
1069
- interactive=True,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1070
  )
1071
 
1072
- with gr.Column(visible=False):
1073
- resample_sr1 = gr.Slider(
1074
- minimum=0,
1075
- maximum=48000,
1076
- label="Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling:",
1077
- value=0,
1078
- step=1,
1079
- interactive=True,
1080
- )
1081
- rms_mix_rate1 = gr.Slider(
1082
- minimum=0,
1083
- maximum=1,
1084
- label="Use the volume envelope of the input to replace or mix with the volume envelope of the output. The closer the ratio is to 1, the more the output envelope is used:",
1085
- value=1,
1086
- interactive=True,
1087
- )
1088
- protect1 = gr.Slider(
1089
- minimum=0,
1090
- maximum=0.5,
1091
- label="Protect voiceless consonants and breath sounds to prevent artifacts such as tearing in electronic music. Set to 0.5 to disable. Decrease the value to increase protection, but it may reduce indexing accuracy:",
1092
- value=0.33,
1093
- step=0.01,
1094
- interactive=True,
1095
- )
1096
- vc_output3 = gr.Textbox(label="Output information:", visible=False)
1097
- but1 = gr.Button("Convert", variant="primary", visible=False)
1098
- but1.click(
1099
- vc.vc_multi,
1100
- [
1101
- spk_item,
1102
- dir_input,
1103
- opt_input,
1104
- inputs,
1105
- vc_transform1,
1106
- f0method1,
1107
- file_index3,
1108
- file_index4,
1109
- index_rate2,
1110
- filter_radius1,
1111
- resample_sr1,
1112
- rms_mix_rate1,
1113
- protect1,
1114
- format1,
1115
- crepe_hop_length,
1116
- minpitch_slider if (not rvc_globals.NotesOrHertz) else minpitch_txtbox,
1117
- maxpitch_slider if (not rvc_globals.NotesOrHertz) else maxpitch_txtbox,
1118
- f0_autotune
1119
- ],
1120
- [vc_output3],
1121
- )
1122
-
1123
  sid0.change(
1124
  fn=vc.get_vc,
1125
  inputs=[sid0, protect0, protect1],
@@ -1128,6 +1133,8 @@ def GradioSetup(UTheme=gr.themes.Soft()):
1128
  if not sid0.value == '':
1129
  spk_item, protect0, protect1 = vc.get_vc(sid0.value, protect0, protect1)
1130
 
 
 
1131
  # Function to toggle advanced settings
1132
  def toggle_advanced_settings_batch(checkbox):
1133
  return {"visible": checkbox, "__type__": "update"}
@@ -1138,6 +1145,7 @@ def GradioSetup(UTheme=gr.themes.Soft()):
1138
  inputs=[advanced_settings_batch_checkbox],
1139
  outputs=[advanced_settings_batch]
1140
  )
 
1141
 
1142
  with gr.Accordion(label="f0method8", visible=False): #Don't Remove
1143
  with gr.Row():
 
501
  import edge_tts
502
  import asyncio
503
 
 
504
  def change_choices_fix():
505
  audio_paths=[]
506
  for filename in os.listdir("./audios"):
 
514
  most_recent_audio = max(audio_paths, key=os.path.getctime)
515
  return {"choices": sorted(audio_paths), "value": most_recent_audio, "__type__": "update"}
516
 
 
517
  def custom_voice(
518
  _values, # filter indices
519
  audio_files, # all audio files
 
735
  label="Advanced Settings",
736
  interactive=True,
737
  )
738
+
739
  # Advanced settings container
740
  with gr.Column(visible=False) as advanced_settings: # Initially hidden
741
  with gr.Row(label = "Advanced Settings", open = False):
 
982
  ],
983
  [vc_output1, vc_output2],
984
  )
985
+ with gr.TabItem(i18n("Batch")): # Dont Change
986
+ with gr.Group(): # Markdown explanation of batch inference
987
+ gr.Markdown(
988
+ value=i18n("Batch conversion. Enter the folder containing the audio files to be converted or upload multiple audio files. The converted audio will be output in the specified folder (default: 'opt').")
989
+ )
990
+ with gr.Row():
991
+ with gr.Column():
992
  vc_transform1 = gr.Number(
993
+ label=i18n("Transpose (integer, number of semitones, raise by an octave: 12, lower by an octave: -12):"), value=0
994
  )
995
+ opt_input = gr.Textbox(label=i18n("Specify output folder:"), value="opt")
996
+ with gr.Column():
997
  file_index4 = gr.Dropdown(
998
+ label=i18n("Auto-detect index path and select from the dropdown:"),
999
  choices=get_indexes(),
1000
+ value=best_match_index_path1,
1001
  interactive=True,
1002
  )
1003
  sid0.select(fn=match_index, inputs=[sid0], outputs=[file_index2, file_index4])
 
1010
  index_rate2 = gr.Slider(
1011
  minimum=0,
1012
  maximum=1,
1013
+ label=i18n("Search feature ratio:"),
1014
  value=0.75,
1015
  interactive=True,
1016
  )
1017
+ with gr.Row():
1018
  dir_input = gr.Textbox(
1019
+ label=i18n("Enter the path of the audio folder to be processed (copy it from the address bar of the file manager):"),
1020
  value=os.path.join(now_dir, "audios"),
1021
  )
1022
  inputs = gr.File(
1023
+ file_count="multiple", label=i18n("You can also input audio files in batches. Choose one of the two options. Priority is given to reading from the folder.")
1024
  )
1025
 
1026
+ with gr.Row():
1027
+ with gr.Column():
1028
  # Create a checkbox for advanced batch settings
1029
  advanced_settings_batch_checkbox = gr.Checkbox(
1030
  value=False,
1031
+ label=i18n("Advanced Settings"),
1032
  interactive=True,
1033
  )
1034
+
1035
+ # Advanced batch settings container
1036
+ with gr.Row(visible=False) as advanced_settings_batch: # Initially hidden
1037
+ with gr.Row(label = i18n("Advanced Settings"), open = False):
1038
+ with gr.Column():
1039
+ file_index3 = gr.Textbox(
1040
+ label=i18n("Feature search database file path:"),
1041
+ value="",
1042
+ interactive=True,
1043
+ )
1044
+
1045
+ f0method1 = gr.Radio(
1046
+ label=i18n(
1047
+ "Select the pitch extraction algorithm:"
1048
+ ),
1049
+ choices=["pm", "harvest", "crepe", "rmvpe"],
1050
+ value="rmvpe",
1051
+ interactive=True,
1052
+ )
1053
+ f0_autotune = gr.Checkbox(
1054
+ label="Enable autotune",
1055
+ interactive=True
1056
+ )
1057
+ filter_radius1 = gr.Slider(
1058
+ minimum=0,
1059
+ maximum=7,
1060
+ label=i18n("If >=3: apply median filtering to the harvested pitch results. The value represents the filter radius and can reduce breathiness."),
1061
+ value=3,
1062
+ step=1,
1063
  interactive=True,
1064
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1065
 
1066
+ with gr.Row():
1067
+ format1 = gr.Radio(
1068
+ label=i18n("Export file format"),
1069
+ choices=["wav", "flac", "mp3", "m4a"],
1070
+ value="wav",
1071
+ interactive=True,
1072
+ )
1073
+
1074
+
1075
+ with gr.Column():
1076
+ resample_sr1 = gr.Slider(
1077
+ minimum=0,
1078
+ maximum=48000,
1079
+ label=i18n("Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling:"),
1080
+ value=0,
1081
+ step=1,
1082
+ interactive=True,
1083
+ )
1084
+ rms_mix_rate1 = gr.Slider(
1085
+ minimum=0,
1086
+ maximum=1,
1087
+ label=i18n("Use the volume envelope of the input to replace or mix with the volume envelope of the output. The closer the ratio is to 1, the more the output envelope is used:"),
1088
+ value=1,
1089
+ interactive=True,
1090
+ )
1091
+ protect1 = gr.Slider(
1092
+ minimum=0,
1093
+ maximum=0.5,
1094
+ label=i18n(
1095
+ "Protect voiceless consonants and breath sounds to prevent artifacts such as tearing in electronic music. Set to 0.5 to disable. Decrease the value to increase protection, but it may reduce indexing accuracy:"
1096
+ ),
1097
+ value=0.33,
1098
+ step=0.01,
1099
+ interactive=True,
1100
+ )
1101
+ vc_output3 = gr.Textbox(label=i18n("Output information:"))
1102
+ but1 = gr.Button(i18n("Convert"), variant="primary")
1103
+ but1.click(
1104
+ vc.vc_multi,
1105
+ [
1106
+ spk_item,
1107
+ dir_input,
1108
+ opt_input,
1109
+ inputs,
1110
+ vc_transform1,
1111
+ f0method1,
1112
+ file_index3,
1113
+ file_index4,
1114
+ index_rate2,
1115
+ filter_radius1,
1116
+ resample_sr1,
1117
+ rms_mix_rate1,
1118
+ protect1,
1119
+ format1,
1120
+ crepe_hop_length,
1121
+ minpitch_slider if (not rvc_globals.NotesOrHertz) else minpitch_txtbox,
1122
+ maxpitch_slider if (not rvc_globals.NotesOrHertz) else maxpitch_txtbox,
1123
+ f0_autotune
1124
+ ],
1125
+ [vc_output3],
1126
  )
1127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1128
  sid0.change(
1129
  fn=vc.get_vc,
1130
  inputs=[sid0, protect0, protect1],
 
1133
  if not sid0.value == '':
1134
  spk_item, protect0, protect1 = vc.get_vc(sid0.value, protect0, protect1)
1135
 
1136
+ #spk_item, protect0, protect1 = vc.get_vc(sid0.value, protect0, protect1)
1137
+
1138
  # Function to toggle advanced settings
1139
  def toggle_advanced_settings_batch(checkbox):
1140
  return {"visible": checkbox, "__type__": "update"}
 
1145
  inputs=[advanced_settings_batch_checkbox],
1146
  outputs=[advanced_settings_batch]
1147
  )
1148
+
1149
 
1150
  with gr.Accordion(label="f0method8", visible=False): #Don't Remove
1151
  with gr.Row():