Musa commited on
Commit
27ccf6a
1 Parent(s): d12d70f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -19,6 +19,10 @@ config = Config()
19
  logging.getLogger("numba").setLevel(logging.WARNING)
20
  limitation = os.getenv("SYSTEM") == "spaces" # limit audio length in huggingface spaces
21
 
 
 
 
 
22
  def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index):
23
  def vc_fn(
24
  input_audio,
@@ -74,20 +78,6 @@ def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index):
74
  return info, (None, None)
75
  return vc_fn
76
 
77
- def load_hubert():
78
- global hubert_model
79
- models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
80
- ["hubert_base.pt"],
81
- suffix="",
82
- )
83
- hubert_model = models[0]
84
- hubert_model = hubert_model.to(config.device)
85
- if config.is_half:
86
- hubert_model = hubert_model.half()
87
- else:
88
- hubert_model = hubert_model.float()
89
- hubert_model.eval()
90
-
91
  def change_to_tts_mode(tts_mode):
92
  if tts_mode:
93
  return gr.Audio.update(visible=False), gr.Textbox.update(visible=True), gr.Dropdown.update(visible=True)
@@ -97,8 +87,12 @@ def change_to_tts_mode(tts_mode):
97
  if __name__ == '__main__':
98
  load_hubert()
99
  models = []
 
100
  tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
101
  voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
 
 
 
102
  if limitation:
103
  with open("weights/model_info.json", "r", encoding="utf-8") as f:
104
  models_info = json.load(f)
 
19
  logging.getLogger("numba").setLevel(logging.WARNING)
20
  limitation = os.getenv("SYSTEM") == "spaces" # limit audio length in huggingface spaces
21
 
22
+ # Load the whisper_large_v2 interface
23
+ whisper_interface = gr.Interface.load("models/openai/whisper-large-v2")
24
+
25
+
26
  def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index):
27
  def vc_fn(
28
  input_audio,
 
78
  return info, (None, None)
79
  return vc_fn
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  def change_to_tts_mode(tts_mode):
82
  if tts_mode:
83
  return gr.Audio.update(visible=False), gr.Textbox.update(visible=True), gr.Dropdown.update(visible=True)
 
87
  if __name__ == '__main__':
88
  load_hubert()
89
  models = []
90
+
91
  tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
92
  voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
93
+
94
+ # Add the whisper_large_v2 model to the models list
95
+ models.append(("Whisper v2", "Whisper v2", "OpenAI", None, whisper_interface))
96
  if limitation:
97
  with open("weights/model_info.json", "r", encoding="utf-8") as f:
98
  models_info = json.load(f)