jacob-c commited on
Commit
b5cc6a6
·
1 Parent(s): b8ff20e
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -11,7 +11,7 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
11
 
12
  # API URLs and headers
13
  AUDIO_API_URL = "https://api-inference.huggingface.co/models/MIT/ast-finetuned-audioset-10-10-0.4593"
14
- JANUS_API_URL = "https://api-inference.huggingface.co/models/deepseek-ai/Janus-1.3B"
15
  headers = {"Authorization": f"Bearer {os.environ.get('HF_TOKEN')}"}
16
 
17
  def format_error(message):
@@ -53,13 +53,20 @@ def generate_lyrics_with_retry(prompt, max_retries=5, initial_wait=2):
53
  "max_new_tokens": 200,
54
  "temperature": 0.7,
55
  "top_p": 0.9,
 
56
  "return_full_text": False
57
  }
58
  }
59
  )
60
 
 
 
 
61
  if response.status_code == 200:
62
- return response.json()[0]["generated_text"]
 
 
 
63
  elif response.status_code == 503:
64
  print(f"Model loading, attempt {attempt + 1}/{max_retries}. Waiting {wait_time} seconds...")
65
  time.sleep(wait_time)
 
11
 
12
  # API URLs and headers
13
  AUDIO_API_URL = "https://api-inference.huggingface.co/models/MIT/ast-finetuned-audioset-10-10-0.4593"
14
+ JANUS_API_URL = "https://api-inference.huggingface.co/models/deepseek-ai/Janus-1.3B/text-generation"
15
  headers = {"Authorization": f"Bearer {os.environ.get('HF_TOKEN')}"}
16
 
17
  def format_error(message):
 
53
  "max_new_tokens": 200,
54
  "temperature": 0.7,
55
  "top_p": 0.9,
56
+ "do_sample": True,
57
  "return_full_text": False
58
  }
59
  }
60
  )
61
 
62
+ print(f"Response status: {response.status_code}")
63
+ print(f"Response content: {response.content.decode('utf-8', errors='ignore')}")
64
+
65
  if response.status_code == 200:
66
+ result = response.json()
67
+ if isinstance(result, list) and len(result) > 0:
68
+ return result[0].get("generated_text", "Error: No text generated")
69
+ return "Error: Unexpected response format"
70
  elif response.status_code == 503:
71
  print(f"Model loading, attempt {attempt + 1}/{max_retries}. Waiting {wait_time} seconds...")
72
  time.sleep(wait_time)