jeevzz commited on
Commit
ca83b72
·
verified ·
1 Parent(s): e00f1a9

Update voice.py

Browse files
Files changed (1) hide show
  1. voice.py +4 -2
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
- audio_bytes = client.text_to_speech(text, model=model)
 
 
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() # Print the full error stack
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...")