Spaces:
Running
Running
Update voice.py
Browse files
voice.py
CHANGED
|
@@ -28,7 +28,7 @@ async def generate_audio(text: str, voice: str) -> str:
|
|
| 28 |
print(f"Edge TTS Failed: {e}. Attempting fallback to HF Inference API...")
|
| 29 |
try:
|
| 30 |
# Fallback 1: Hugging Face Inference API (Realistic Female Voice)
|
| 31 |
-
# using
|
| 32 |
from huggingface_hub import InferenceClient
|
| 33 |
from dotenv import load_dotenv
|
| 34 |
from pathlib import Path
|
|
@@ -41,8 +41,7 @@ async def generate_audio(text: str, voice: str) -> str:
|
|
| 41 |
client = InferenceClient(token=hf_token)
|
| 42 |
|
| 43 |
# Generate audio using HF API
|
| 44 |
-
|
| 45 |
-
audio_bytes = client.text_to_speech(text, model="espnet/kan-bayashi_ljspeech_vits")
|
| 46 |
|
| 47 |
fd, path = tempfile.mkstemp(suffix=".flac") # Model returns flac usually
|
| 48 |
os.close(fd)
|
|
|
|
| 28 |
print(f"Edge TTS Failed: {e}. Attempting fallback to HF Inference API...")
|
| 29 |
try:
|
| 30 |
# Fallback 1: Hugging Face Inference API (Realistic Female Voice)
|
| 31 |
+
# using facebook/mms-tts-eng (Very reliable)
|
| 32 |
from huggingface_hub import InferenceClient
|
| 33 |
from dotenv import load_dotenv
|
| 34 |
from pathlib import Path
|
|
|
|
| 41 |
client = InferenceClient(token=hf_token)
|
| 42 |
|
| 43 |
# Generate audio using HF API
|
| 44 |
+
audio_bytes = client.text_to_speech(text, model="facebook/mms-tts-eng")
|
|
|
|
| 45 |
|
| 46 |
fd, path = tempfile.mkstemp(suffix=".flac") # Model returns flac usually
|
| 47 |
os.close(fd)
|