Update app.py
Browse files
app.py
CHANGED
|
@@ -8,34 +8,23 @@ import spaces
|
|
| 8 |
import cv2
|
| 9 |
import numpy as np
|
| 10 |
from PIL import Image
|
| 11 |
-
import
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
import soundfile as sf
|
| 16 |
|
| 17 |
-
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
| 18 |
-
|
| 19 |
-
tts_model = ParlerTTSForConditionalGeneration.from_pretrained("CONCREE/Adia_TTS").to(device)
|
| 20 |
-
tts_tokenizer = AutoTokenizer.from_pretrained("CONCREE/Adia_TTS")
|
| 21 |
-
|
| 22 |
-
@spaces.GPU
|
| 23 |
def tts(text):
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
)
|
| 36 |
-
sf.write(output_wav_path, audio.cpu().numpy().squeeze(), tts_model.config.sampling_rate) # Fixed: was 'model.config'
|
| 37 |
-
|
| 38 |
-
return output_wav_path
|
| 39 |
|
| 40 |
|
| 41 |
def progress_bar_html(label: str) -> str:
|
|
|
|
| 8 |
import cv2
|
| 9 |
import numpy as np
|
| 10 |
from PIL import Image
|
| 11 |
+
from gradio_client import Client, handle_file
|
| 12 |
|
| 13 |
+
# Initialize TTS client
|
| 14 |
+
tts_client = Client("dofbi/galsenai-xtts-v2-wolof-inference")
|
|
|
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def tts(text):
|
| 17 |
+
"""Generate TTS using Gradio API client"""
|
| 18 |
+
try:
|
| 19 |
+
result = tts_client.predict(
|
| 20 |
+
text=text,
|
| 21 |
+
audio_reference=handle_file('https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav'),
|
| 22 |
+
api_name="/predict"
|
| 23 |
+
)
|
| 24 |
+
return result
|
| 25 |
+
except Exception as e:
|
| 26 |
+
print(f"TTS API Error: {e}")
|
| 27 |
+
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
def progress_bar_html(label: str) -> str:
|