r3gm commited on
Commit
dda808a
1 Parent(s): ba25927

Update app_rvc.py

Browse files
Files changed (1) hide show
  1. app_rvc.py +34 -3
app_rvc.py CHANGED
@@ -4,6 +4,7 @@ os.system("pip install -q piper-tts==1.2.0")
4
  os.system("pip install -q -r requirements_xtts.txt")
5
  os.system("pip install -q TTS==0.21.1 --no-deps")
6
  import spaces
 
7
  from soni_translate.logging_setup import (
8
  logger,
9
  set_logging_level,
@@ -661,6 +662,31 @@ class SoniTranslate(SoniTrCache):
661
  logger.info(f"Done: {output}")
662
  return output
663
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
664
  if not self.task_in_cache("refine_vocals", [vocal_refinement], {}):
665
  self.vocals = None
666
  if vocal_refinement:
@@ -1308,9 +1334,14 @@ class SoniTranslate(SoniTrCache):
1308
  if not document:
1309
  raise Exception("No data found")
1310
 
1311
- if os.environ.get("ZERO_GPU") == "TRUE" and not is_string:
1312
- raise RuntimeError("This option is disabled in this demo.")
1313
-
 
 
 
 
 
1314
  if "videobook" in output_type:
1315
  if not document.lower().endswith(".pdf"):
1316
  raise ValueError(
 
4
  os.system("pip install -q -r requirements_xtts.txt")
5
  os.system("pip install -q TTS==0.21.1 --no-deps")
6
  import spaces
7
+ import librosa
8
  from soni_translate.logging_setup import (
9
  logger,
10
  set_logging_level,
 
662
  logger.info(f"Done: {output}")
663
  return output
664
 
665
+ if os.environ.get("IS_DEMO") == "TRUE":
666
+ duration_verify = librosa.get_duration(filename=base_audio_wav)
667
+ logger.info(f"Duration: {duration_verify} seconds")
668
+ if duration_verify > 1500:
669
+ raise RuntimeError(
670
+ "The audio is too long to process in this demo. Alternatively, you"
671
+ " can install the app locally or use the Colab notebook available "
672
+ "in the SoniTranslate repository."
673
+ )
674
+ elif duration_verify > 300:
675
+ tts_voices_list = [
676
+ tts_voice00, tts_voice01, tts_voice02, tts_voice03, tts_voice04,
677
+ tts_voice05, tts_voice06, tts_voice07, tts_voice08, tts_voice09,
678
+ tts_voice10, tts_voice11
679
+ ]
680
+
681
+ for tts_voice_ in tts_voices_list:
682
+ if "_XTTS_" in tts_voice_:
683
+ raise RuntimeError(
684
+ "XTTS is too slow to be used for audio longer than 5 "
685
+ "minutes in this demo. Alternatively, you can install "
686
+ "the app locally or use the Colab notebook available in"
687
+ " the SoniTranslate repository."
688
+ )
689
+
690
  if not self.task_in_cache("refine_vocals", [vocal_refinement], {}):
691
  self.vocals = None
692
  if vocal_refinement:
 
1334
  if not document:
1335
  raise Exception("No data found")
1336
 
1337
+ if os.environ.get("IS_DEMO") == "TRUE" and not is_string:
1338
+ raise RuntimeError(
1339
+ "This option is disabled in this demo. "
1340
+ "Alternatively, you can install "
1341
+ "the app locally or use the Colab notebook available in"
1342
+ " the SoniTranslate repository."
1343
+ )
1344
+
1345
  if "videobook" in output_type:
1346
  if not document.lower().endswith(".pdf"):
1347
  raise ValueError(