Ruslan Magana Vsevolodovna commited on
Commit
1887906
2 Parent(s): a974282 4a8116d

Merge branch 'v3'

Browse files
Files changed (2) hide show
  1. app.py +49 -3
  2. requirements.txt +0 -0
app.py CHANGED
@@ -231,6 +231,20 @@ def play_audio(generated_wav,sample_rate):
231
  print("Continuing without audio playback. Suppress this message with the \"--no_sound\" flag.\n")
232
  except:
233
  raise
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
  def clone_voice(in_fpath, text):
236
  try:
@@ -271,9 +285,36 @@ USE_CUDA = torch.cuda.is_available()
271
  os.system('pip install -q pydub ffmpeg-normalize')
272
  CONFIG_SE_PATH = "config_se.json"
273
  CHECKPOINT_SE_PATH = "SE_checkpoint.pth.tar"
274
- def greet(Text,Voicetoclone):
275
  text= "%s" % (Text)
276
  #reference_files= "%s" % (Voicetoclone)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  reference_files= Voicetoclone
278
  print("path url")
279
  print(Voicetoclone)
@@ -309,7 +350,12 @@ demo = gr.Interface(
309
  gr.Audio(
310
  type="filepath",
311
  source="upload",
312
- label='Please upload a voice to clone (max. 30mb)')
 
 
 
 
 
313
 
314
  ],
315
  outputs="audio",
@@ -325,7 +371,7 @@ demo = gr.Interface(
325
  </div>''',
326
 
327
  examples = [
328
- ["I am the cloned version of Donald Trump. Well, I think what's happening to this country is unbelievably bad. We're no longer a respected country" ,"trump.mp3"]
329
 
330
  ]
331
 
 
231
  print("Continuing without audio playback. Suppress this message with the \"--no_sound\" flag.\n")
232
  except:
233
  raise
234
+
235
+
236
+ def clean_memory():
237
+ import gc
238
+ #import GPUtil
239
+ # To see memory usage
240
+ print('Before clean ')
241
+ #GPUtil.showUtilization()
242
+ #cleaning memory 1
243
+ gc.collect()
244
+ torch.cuda.empty_cache()
245
+ time.sleep(2)
246
+ print('After Clean GPU')
247
+ #GPUtil.showUtilization()
248
 
249
  def clone_voice(in_fpath, text):
250
  try:
 
285
  os.system('pip install -q pydub ffmpeg-normalize')
286
  CONFIG_SE_PATH = "config_se.json"
287
  CHECKPOINT_SE_PATH = "SE_checkpoint.pth.tar"
288
+ def greet(Text,Voicetoclone ,input_mic=None):
289
  text= "%s" % (Text)
290
  #reference_files= "%s" % (Voicetoclone)
291
+
292
+ clean_memory()
293
+ print(text,len(text),type(text))
294
+ print(Voicetoclone,type(Voicetoclone))
295
+
296
+ if len(text) == 0 :
297
+ print("Please add text to the program")
298
+ Text="Please add text to the program, thank you."
299
+ is_no_text=True
300
+ else:
301
+ is_no_text=False
302
+
303
+
304
+ if Voicetoclone==None and input_mic==None:
305
+ print("There is no input audio")
306
+ Text="Please add audio input, to the program, thank you."
307
+ Voicetoclone='trump.mp3'
308
+ if is_no_text:
309
+ Text="Please add text and audio, to the program, thank you."
310
+
311
+ if input_mic != None:
312
+ # Get the wav file from the microphone
313
+ print('The value of MIC IS :',input_mic,type(input_mic))
314
+ Voicetoclone= input_mic
315
+
316
+
317
+ text= "%s" % (Text)
318
  reference_files= Voicetoclone
319
  print("path url")
320
  print(Voicetoclone)
 
350
  gr.Audio(
351
  type="filepath",
352
  source="upload",
353
+ label='Please upload a voice to clone (max. 30mb)'),
354
+ gr.inputs.Audio(
355
+ source="microphone",
356
+ label='or record',
357
+ type="filepath",
358
+ optional=True)
359
 
360
  ],
361
  outputs="audio",
 
371
  </div>''',
372
 
373
  examples = [
374
+ ["I am the cloned version of Donald Trump. Well. I think what's happening to this country is unbelievably bad. We're no longer a respected country" ,"trump.mp3",]
375
 
376
  ]
377
 
requirements.txt CHANGED
Binary files a/requirements.txt and b/requirements.txt differ