Spaces:
Running
Running
Update voice.py
Browse files
voice.py
CHANGED
|
@@ -54,7 +54,9 @@ async def generate_audio(text: str, voice: str) -> str:
|
|
| 54 |
for model in models:
|
| 55 |
try:
|
| 56 |
print(f"Attempting HF Inference with model: {model}")
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
print(f"HF Inference successful with {model}, received {len(audio_bytes)} bytes")
|
| 59 |
|
| 60 |
fd, path = tempfile.mkstemp(suffix=".flac")
|
|
@@ -66,7 +68,7 @@ async def generate_audio(text: str, voice: str) -> str:
|
|
| 66 |
return path
|
| 67 |
except Exception as model_err:
|
| 68 |
print(f"HF Model {model} failed: {model_err}")
|
| 69 |
-
traceback.print_exc() #
|
| 70 |
continue # Try next model
|
| 71 |
|
| 72 |
print("All HF models failed. Moving to gTTS...")
|
|
|
|
| 54 |
for model in models:
|
| 55 |
try:
|
| 56 |
print(f"Attempting HF Inference with model: {model}")
|
| 57 |
+
# Use direct POST to bypass client-side provider lookup issues
|
| 58 |
+
# The API returns raw audio bytes for TTS models
|
| 59 |
+
audio_bytes = client.post(json={"inputs": text}, model=model)
|
| 60 |
print(f"HF Inference successful with {model}, received {len(audio_bytes)} bytes")
|
| 61 |
|
| 62 |
fd, path = tempfile.mkstemp(suffix=".flac")
|
|
|
|
| 68 |
return path
|
| 69 |
except Exception as model_err:
|
| 70 |
print(f"HF Model {model} failed: {model_err}")
|
| 71 |
+
# traceback.print_exc() # Reduce noise
|
| 72 |
continue # Try next model
|
| 73 |
|
| 74 |
print("All HF models failed. Moving to gTTS...")
|