Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,33 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
import traceback
|
| 4 |
|
| 5 |
def generate_audio(prompt, duration=10):
|
| 6 |
-
updates = []
|
| 7 |
try:
|
| 8 |
-
updates
|
|
|
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
| 16 |
-
updates.append("β
Stable Audio Tools imported")
|
| 17 |
|
| 18 |
from huggingface_hub import hf_hub_download
|
| 19 |
-
updates.append("
|
| 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("β
|
| 27 |
|
| 28 |
-
return "\n".join(updates) + f"\n\nπ― Ready to generate: '{prompt}'
|
| 29 |
|
| 30 |
except Exception as e:
|
| 31 |
-
|
| 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="
|
| 41 |
-
title="π§
|
| 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()
|