Amamrnaf commited on
Commit
9232118
·
1 Parent(s): b94855f
Files changed (2) hide show
  1. app.py +6 -1
  2. coqui_tts.py +1 -0
app.py CHANGED
@@ -2,13 +2,18 @@ import gradio as gr
2
  import os
3
  from coqui_tts import run_audio_generation_v1
4
  import shutil
 
5
 
6
  def process_audio(input_text, speaker_audio, speaker_name, option_selected):
7
  try:
8
  # Ensure necessary directories exist
9
  os.makedirs("./tmp/audio/input_src/", exist_ok=True)
10
  os.makedirs("audio", exist_ok=True)
11
-
 
 
 
 
12
  # Copy speaker audio to the required location
13
  speaker_audio_path = "./tmp/audio/input_src/0.wav"
14
  if os.path.exists(speaker_audio):
 
2
  import os
3
  from coqui_tts import run_audio_generation_v1
4
  import shutil
5
+ os.environ["COQUI_LICENSE"] = "1" # Automatically agrees to the non-commercial license
6
 
7
  def process_audio(input_text, speaker_audio, speaker_name, option_selected):
8
  try:
9
  # Ensure necessary directories exist
10
  os.makedirs("./tmp/audio/input_src/", exist_ok=True)
11
  os.makedirs("audio", exist_ok=True)
12
+ print(f"Received audio file: {speaker_audio}")
13
+
14
+ if not speaker_audio or not os.path.exists(speaker_audio):
15
+ return "Error: The uploaded audio file is missing or invalid. Please upload again."
16
+
17
  # Copy speaker audio to the required location
18
  speaker_audio_path = "./tmp/audio/input_src/0.wav"
19
  if os.path.exists(speaker_audio):
coqui_tts.py CHANGED
@@ -13,6 +13,7 @@ import torch
13
  from TTS.api import TTS
14
 
15
 
 
16
  def run_audio_generation_v1(text,accent='None'):
17
  gpu = True if torch.cuda.is_available() else False
18
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=gpu) # gpu should be true when server (cuda)
 
13
  from TTS.api import TTS
14
 
15
 
16
+
17
  def run_audio_generation_v1(text,accent='None'):
18
  gpu = True if torch.cuda.is_available() else False
19
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=gpu) # gpu should be true when server (cuda)