Den Pavloff commited on
Commit
e9bcb5a
·
1 Parent(s): 5261d4e

load_models

Browse files
Files changed (1) hide show
  1. app.py +22 -15
app.py CHANGED
@@ -54,23 +54,30 @@ models_configs = {
54
  player = NemoAudioPlayer(Config())
55
  demo_examples = Demo()()
56
  models = {}
 
 
 
 
 
57
 
58
- def initialize_models():
59
- """Initialize models globally to avoid reloading"""
60
- global models
 
 
61
 
62
- # if player is None:
63
- # print("Initializing NeMo Audio Player...")
64
- # player = NemoAudioPlayer(Config())
65
- # print("NeMo Audio Player initialized!")
66
 
67
- if not models:
68
- print("Loading TTS models...")
69
- for model_name, config in models_configs.items():
70
- print(f"Loading {model_name}...")
71
- models[model_name] = KaniModel(config, player, token_)
72
- print(f"{model_name} loaded!")
73
- print("All models loaded!")
74
 
75
  @spaces.GPU
76
  def generate_speech_gpu(text, model_choice):
@@ -78,7 +85,7 @@ def generate_speech_gpu(text, model_choice):
78
  Generate speech from text using the selected model on GPU
79
  """
80
  # Initialize models if not already done
81
- initialize_models()
82
 
83
  if not text.strip():
84
  return None, "Please enter text for speech generation."
 
54
  player = NemoAudioPlayer(Config())
55
  demo_examples = Demo()()
56
  models = {}
57
+ for model_name, config in models_configs.items():
58
+ print(f"Loading {model_name}...")
59
+ models[model_name] = KaniModel(config, player, token_)
60
+ print(f"{model_name} loaded!")
61
+ print("All models loaded!")
62
 
63
+
64
+
65
+ # def initialize_models():
66
+ # """Initialize models globally to avoid reloading"""
67
+ # global models
68
 
69
+ # # if player is None:
70
+ # # print("Initializing NeMo Audio Player...")
71
+ # # player = NemoAudioPlayer(Config())
72
+ # # print("NeMo Audio Player initialized!")
73
 
74
+ # if not models:
75
+ # print("Loading TTS models...")
76
+ # for model_name, config in models_configs.items():
77
+ # print(f"Loading {model_name}...")
78
+ # models[model_name] = KaniModel(config, player, token_)
79
+ # print(f"{model_name} loaded!")
80
+ # print("All models loaded!")
81
 
82
  @spaces.GPU
83
  def generate_speech_gpu(text, model_choice):
 
85
  Generate speech from text using the selected model on GPU
86
  """
87
  # Initialize models if not already done
88
+ # initialize_models()
89
 
90
  if not text.strip():
91
  return None, "Please enter text for speech generation."