@@ -122,6 +122,7 @@ def get_files(type="model"):
122122
123123
124124default_weight = next (iter (get_files ("model" )), None )
125+ index_files = sorted (get_files ("index" ))
125126
126127audio_paths = [
127128 os .path .join (root , name )
@@ -228,8 +229,10 @@ def change_choices(model):
228229 else :
229230 speakers = [0 ]
230231
231- models_list = get_files ("model" )
232+ models_list = sorted ( get_files ("model" ) )
232233 indexes_list = sorted (get_files ("index" ))
234+ if indexes_list :
235+ indexes_list = [("No Index" , "" )] + [(x , x ) for x in indexes_list ]
233236
234237 audio_paths = [
235238 os .path .join (root , name )
@@ -241,8 +244,8 @@ def change_choices(model):
241244 ]
242245
243246 return (
244- {"choices" : sorted ( models_list ) , "__type__" : "update" },
245- {"choices" : sorted ( indexes_list ) , "__type__" : "update" },
247+ {"choices" : models_list , "__type__" : "update" },
248+ {"choices" : indexes_list , "__type__" : "update" },
246249 {"choices" : sorted (audio_paths ), "__type__" : "update" },
247250 {
248251 "choices" : (
@@ -483,6 +486,8 @@ def filter_dropdowns(filter_text):
483486 all_indexes = sorted (get_files ("index" ))
484487 filtered_models = [m for m in all_models if ft in m .lower ()]
485488 filtered_indexes = [i for i in all_indexes if ft in i .lower ()]
489+ if filtered_indexes :
490+ filtered_indexes = [("No Index" , "" )] + [(x , x ) for x in filtered_indexes ]
486491 return (gr .update (choices = filtered_models ), gr .update (choices = filtered_indexes ))
487492
488493
@@ -519,7 +524,9 @@ def inference_tab():
519524 index_file = gr .Dropdown (
520525 label = i18n ("Index File" ),
521526 info = i18n ("Select the index file to use for the conversion." ),
522- choices = sorted (get_files ("index" )),
527+ choices = [("No Index" , "" )] + [(x , x ) for x in index_files ]
528+ if index_files
529+ else [],
523530 value = match_index (default_weight ),
524531 interactive = True ,
525532 allow_custom_value = True ,
0 commit comments