Nymbo commited on
Commit
0907a02
·
verified ·
1 Parent(s): 77dfc08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -75,12 +75,8 @@ def _init_pocket(
75
  import os
76
  hf_token = os.environ.get("HF_TOKEN")
77
  if hf_token:
78
- try:
79
- from huggingface_hub import login
80
- login(token=hf_token, add_to_git_credential=False)
81
- print("Logged in to HuggingFace")
82
- except Exception as e:
83
- print(f"HuggingFace login failed: {e}")
84
 
85
  # Auto-detect device: CPU by default, CUDA if available
86
  # Note: The pocket-tts docs mention GPU doesn't provide speedup for this model
@@ -276,6 +272,13 @@ def _get_voice_state(voice_name: str | None, custom_audio_path: str | None):
276
  return voice_state
277
 
278
  # Fall back to voice cloning (requires auth)
 
 
 
 
 
 
 
279
  voice_path = PRESET_VOICES[voice_name]
280
  print(f"Loading preset voice '{voice_name}' from: {voice_path}")
281
 
@@ -432,8 +435,17 @@ def generate_tts(
432
  with gr.Blocks() as demo:
433
  gr.HTML(
434
  "<h1 style='text-align: center;'>Pocket-TTS</h1>"
435
- "<p style='text-align: center;'>Powered by kyutai/pocket-tts | Lightweight TTS on CPU</p>"
436
  )
 
 
 
 
 
 
 
 
 
 
437
 
438
  with gr.Row():
439
  with gr.Column():
 
75
  import os
76
  hf_token = os.environ.get("HF_TOKEN")
77
  if hf_token:
78
+ print("HF_TOKEN found, using for authentication")
79
+
 
 
 
 
80
 
81
  # Auto-detect device: CPU by default, CUDA if available
82
  # Note: The pocket-tts docs mention GPU doesn't provide speedup for this model
 
272
  return voice_state
273
 
274
  # Fall back to voice cloning (requires auth)
275
+ if not model.has_voice_cloning:
276
+ raise gr.Error(
277
+ f"No embedding found for voice '{voice_name}'. "
278
+ f"Voice cloning is not available (requires HF auth). "
279
+ f"Run the app locally first to create embeddings."
280
+ )
281
+
282
  voice_path = PRESET_VOICES[voice_name]
283
  print(f"Loading preset voice '{voice_name}' from: {voice_path}")
284
 
 
435
  with gr.Blocks() as demo:
436
  gr.HTML(
437
  "<h1 style='text-align: center;'>Pocket-TTS</h1>"
 
438
  )
439
+ device_info = gr.Markdown(
440
+ "<p style='text-align: center;'>Powered by kyutai/pocket-tts | Running on CPU</p>"
441
+ )
442
+
443
+ @demo.load
444
+ def update_device_info():
445
+ device = "CUDA" if torch.cuda.is_available() else "CPU"
446
+ return f"<p style='text-align: center;'>Powered by kyutai/pocket-tts | Running on {device}</p>"
447
+
448
+ demo.load(update_device_info, outputs=device_info)
449
 
450
  with gr.Row():
451
  with gr.Column():