mrfakename commited on
Commit
dc46588
1 Parent(s): c09bde4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -477,9 +477,9 @@ def doloudnorm(path):
477
  loudness = meter.integrated_loudness(data)
478
  loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -12.0)
479
  sf.write(path, loudness_normalized_audio, rate)
480
- ############
481
- # 2x speedup (hopefully)
482
- ############
483
 
484
  def synthandreturn(text):
485
  text = text.strip()
@@ -488,6 +488,7 @@ def synthandreturn(text):
488
  if len(text) < MIN_SAMPLE_TXT_LENGTH:
489
  raise gr.Error(f'Not enough text')
490
  if (toxicity.predict(text)['toxicity'] > 0.5):
 
491
  raise gr.Error('Your text failed the toxicity test')
492
  if not text:
493
  raise gr.Error(f'You did not enter any text')
@@ -496,7 +497,7 @@ def synthandreturn(text):
496
  log_text(text)
497
  print("[debug] Using", mdl1, mdl2)
498
  def predict_and_update_result(text, model, result_storage):
499
- result = router.predict(text, AVAILABLE_MODELS[model], api_name="/synthesize")
500
  doloudnorm(result)
501
  result_storage[model] = result
502
  results = {}
 
477
  loudness = meter.integrated_loudness(data)
478
  loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -12.0)
479
  sf.write(path, loudness_normalized_audio, rate)
480
+ ##########################
481
+ # 2x speedup (hopefully) #
482
+ ##########################
483
 
484
  def synthandreturn(text):
485
  text = text.strip()
 
488
  if len(text) < MIN_SAMPLE_TXT_LENGTH:
489
  raise gr.Error(f'Not enough text')
490
  if (toxicity.predict(text)['toxicity'] > 0.5):
491
+ print(f'Detected toxic content! "{text}"')
492
  raise gr.Error('Your text failed the toxicity test')
493
  if not text:
494
  raise gr.Error(f'You did not enter any text')
 
497
  log_text(text)
498
  print("[debug] Using", mdl1, mdl2)
499
  def predict_and_update_result(text, model, result_storage):
500
+ result = router.predict(text, AVAILABLE_MODELS[model].lower(), api_name="/synthesize")
501
  doloudnorm(result)
502
  result_storage[model] = result
503
  results = {}