ybang commited on
Commit
3578727
Β·
verified Β·
1 Parent(s): 5042ce1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -18
app.py CHANGED
@@ -1,35 +1,33 @@
1
  import gradio as gr
2
- import sys
3
  import traceback
4
 
5
  def generate_audio(prompt, duration=10):
6
- updates = []
7
  try:
8
- updates.append("πŸ”„ Starting...")
 
9
 
10
- # Test basic imports first
11
- updates.append("πŸ“¦ Testing imports...")
12
- import torch
13
- updates.append(f"βœ… PyTorch: {torch.__version__}")
14
 
15
- import stable_audio_tools
16
- updates.append("βœ… Stable Audio Tools imported")
17
 
18
  from huggingface_hub import hf_hub_download
19
- updates.append("βœ… HuggingFace Hub ready")
20
 
21
- updates.append("⬇️ Attempting model download...")
22
  model_config = hf_hub_download(
23
  repo_id="stabilityai/stable-audio-open-1.0",
24
- filename="model_config.json"
 
25
  )
26
- updates.append("βœ… Config downloaded")
27
 
28
- return "\n".join(updates) + f"\n\n🎯 Ready to generate: '{prompt}' for {duration}s"
29
 
30
  except Exception as e:
31
- error_details = traceback.format_exc()
32
- return f"❌ Error: {str(e)}\n\nFull error:\n{error_details}"
33
 
34
  demo = gr.Interface(
35
  fn=generate_audio,
@@ -37,8 +35,8 @@ demo = gr.Interface(
37
  gr.Textbox(label="Prompt", value="heavy boots thudding on wet sand"),
38
  gr.Slider(5, 20, 10, label="Duration")
39
  ],
40
- outputs=gr.Textbox(label="Debug Info", lines=10),
41
- title="πŸ”§ Debug Mode"
42
  )
43
 
44
  demo.launch()
 
1
  import gradio as gr
2
+ import os
3
  import traceback
4
 
5
  def generate_audio(prompt, duration=10):
 
6
  try:
7
+ updates = []
8
+ updates.append("πŸ”„ Starting with authentication...")
9
 
10
+ # Get token from environment
11
+ token = os.getenv("HF_TOKEN")
12
+ if not token:
13
+ return "❌ No HF_TOKEN found in environment variables"
14
 
15
+ updates.append("βœ… Token found")
 
16
 
17
  from huggingface_hub import hf_hub_download
18
+ updates.append("πŸ“¦ Downloading with token...")
19
 
 
20
  model_config = hf_hub_download(
21
  repo_id="stabilityai/stable-audio-open-1.0",
22
+ filename="model_config.json",
23
+ token=token
24
  )
25
+ updates.append("βœ… Model config downloaded!")
26
 
27
+ return "\n".join(updates) + f"\n\n🎯 Ready to generate: '{prompt}'"
28
 
29
  except Exception as e:
30
+ return f"❌ Error: {str(e)}\n\n{traceback.format_exc()}"
 
31
 
32
  demo = gr.Interface(
33
  fn=generate_audio,
 
35
  gr.Textbox(label="Prompt", value="heavy boots thudding on wet sand"),
36
  gr.Slider(5, 20, 10, label="Duration")
37
  ],
38
+ outputs=gr.Textbox(label="Status", lines=8),
39
+ title="πŸ”§ Token Test"
40
  )
41
 
42
  demo.launch()