Spaces:
Runtime error
Runtime error
- app.py +7 -3
- model.py +0 -1
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -50,6 +50,12 @@ def get_mytts(text: str, voice: str, base_url: str):
|
|
| 50 |
)
|
| 51 |
return response.json()
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
async def response(
|
| 55 |
audio: tuple[int, np.ndarray],
|
|
@@ -92,9 +98,7 @@ async def response(
|
|
| 92 |
audio_array = wav.reshape(1, -1)
|
| 93 |
yield (result['sampling_rate'], audio_array)
|
| 94 |
elif is_gpu and not tts_url:
|
| 95 |
-
|
| 96 |
-
audio_array = np.array(wav, dtype=np.float32).reshape(1, -1)
|
| 97 |
-
yield (sampling_rate, audio_array)
|
| 98 |
else:
|
| 99 |
raise ValueError("No TTS URL provided and GPU not available")
|
| 100 |
|
|
|
|
| 50 |
)
|
| 51 |
return response.json()
|
| 52 |
|
| 53 |
+
if is_gpu:
|
| 54 |
+
@spaces.GPU
|
| 55 |
+
def tts_gpu(text: str, voice: str):
|
| 56 |
+
wav, sampling_rate = generate_tts(text, voice, 1)
|
| 57 |
+
audio_array = np.array(wav, dtype=np.float32).reshape(1, -1)
|
| 58 |
+
return (sampling_rate, audio_array)
|
| 59 |
|
| 60 |
async def response(
|
| 61 |
audio: tuple[int, np.ndarray],
|
|
|
|
| 98 |
audio_array = wav.reshape(1, -1)
|
| 99 |
yield (result['sampling_rate'], audio_array)
|
| 100 |
elif is_gpu and not tts_url:
|
| 101 |
+
yield tts_gpu(text, voice)
|
|
|
|
|
|
|
| 102 |
else:
|
| 103 |
raise ValueError("No TTS URL provided and GPU not available")
|
| 104 |
|
model.py
CHANGED
|
@@ -75,7 +75,6 @@ CLONE_VOICES = {
|
|
| 75 |
|
| 76 |
f5tts = F5TTS(ckpt_file=model_path, vocab_file='vocab.txt', device='cuda')
|
| 77 |
|
| 78 |
-
@spaces.GPU()
|
| 79 |
def generate_tts(gen_text, voice, speed):
|
| 80 |
wav, sampling_rate, _ = f5tts.infer(
|
| 81 |
ref_file=f'ref/{CLONE_VOICES[voice]["path"]}',
|
|
|
|
| 75 |
|
| 76 |
f5tts = F5TTS(ckpt_file=model_path, vocab_file='vocab.txt', device='cuda')
|
| 77 |
|
|
|
|
| 78 |
def generate_tts(gen_text, voice, speed):
|
| 79 |
wav, sampling_rate, _ = f5tts.infer(
|
| 80 |
ref_file=f'ref/{CLONE_VOICES[voice]["path"]}',
|
requirements.txt
CHANGED
|
@@ -28,7 +28,7 @@ wandb
|
|
| 28 |
x_transformers>=1.31.14
|
| 29 |
matplotlib
|
| 30 |
accelerate>=0.33.0,!=1.7.0
|
| 31 |
-
bitsandbytes>0.37.0
|
| 32 |
click
|
| 33 |
datasets
|
| 34 |
ema_pytorch>=0.5.2
|
|
|
|
| 28 |
x_transformers>=1.31.14
|
| 29 |
matplotlib
|
| 30 |
accelerate>=0.33.0,!=1.7.0
|
| 31 |
+
bitsandbytes>0.37.0
|
| 32 |
click
|
| 33 |
datasets
|
| 34 |
ema_pytorch>=0.5.2
|