Plachta commited on
Commit
26121a4
1 Parent(s): 71850a7
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -117,6 +117,7 @@ def transcribe_one(model, audio_path):
117
 
118
  # delete all variables
119
  del audio, mel, probs, result
 
120
  return lang, text_pr
121
 
122
  def make_npz_prompt(name, uploaded_audio, recorded_audio, transcript_content):
@@ -161,7 +162,7 @@ def make_npz_prompt(name, uploaded_audio, recorded_audio, transcript_content):
161
 
162
  # delete all variables
163
  del audio_tokens, text_tokens, phonemes, lang_pr, text_pr, wav_pr, sr, uploaded_audio, recorded_audio
164
-
165
  return message, os.path.join(tempfile.gettempdir(), f"{name}.npz")
166
 
167
 
@@ -186,7 +187,7 @@ def make_prompt(name, wav, sr, save=True):
186
  os.remove(f"./prompts/{name}.txt")
187
  # delete all variables
188
  del lang_token, wav, sr
189
-
190
  return text, lang
191
 
192
  @torch.no_grad()
@@ -262,6 +263,7 @@ def infer_from_audio(text, language, accent, audio_prompt, record_audio_prompt,
262
  message = f"text prompt: {text_pr}\nsythesized text: {text}"
263
  # delete all variables
264
  del audio_prompts, text_tokens, text_prompts, phone_tokens, encoded_frames, wav_pr, sr, audio_prompt, record_audio_prompt, transcript_content
 
265
  return message, (24000, samples[0][0].cpu().numpy())
266
 
267
  @torch.no_grad()
@@ -321,6 +323,7 @@ def infer_from_prompt(text, language, accent, preset_prompt, prompt_file):
321
 
322
  # delete all variables
323
  del audio_prompts, text_tokens, text_prompts, phone_tokens, encoded_frames, prompt_file, preset_prompt
 
324
  return message, (24000, samples[0][0].cpu().numpy())
325
 
326
 
 
117
 
118
  # delete all variables
119
  del audio, mel, probs, result
120
+ gc.collect()
121
  return lang, text_pr
122
 
123
  def make_npz_prompt(name, uploaded_audio, recorded_audio, transcript_content):
 
162
 
163
  # delete all variables
164
  del audio_tokens, text_tokens, phonemes, lang_pr, text_pr, wav_pr, sr, uploaded_audio, recorded_audio
165
+ gc.collect()
166
  return message, os.path.join(tempfile.gettempdir(), f"{name}.npz")
167
 
168
 
 
187
  os.remove(f"./prompts/{name}.txt")
188
  # delete all variables
189
  del lang_token, wav, sr
190
+ gc.collect()
191
  return text, lang
192
 
193
  @torch.no_grad()
 
263
  message = f"text prompt: {text_pr}\nsythesized text: {text}"
264
  # delete all variables
265
  del audio_prompts, text_tokens, text_prompts, phone_tokens, encoded_frames, wav_pr, sr, audio_prompt, record_audio_prompt, transcript_content
266
+ gc.collect()
267
  return message, (24000, samples[0][0].cpu().numpy())
268
 
269
  @torch.no_grad()
 
323
 
324
  # delete all variables
325
  del audio_prompts, text_tokens, text_prompts, phone_tokens, encoded_frames, prompt_file, preset_prompt
326
+ gc.collect()
327
  return message, (24000, samples[0][0].cpu().numpy())
328
 
329