Spaces:
Running
Running
File size: 668 Bytes
da0b02a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import requests
from dotenv import load_dotenv
import os
load_dotenv()
_CHUTES_API_KEY = os.getenv("CHUTES_API_KEY")
def generate_music(prompt, lyrics=None, audio_b64=None):
api_token = _CHUTES_API_KEY
headers = {
"Authorization": "Bearer " + api_token,
"Content-Type": "application/json"
}
body = {
"style_prompt": prompt,
"lyrics": lyrics,
"audio_b64": audio_b64
}
response = requests.post(
"https://chutes-diffrhythm.chutes.ai/generate",
headers=headers,
json=body
)
# Print status code and response
print(f"Status code: {response.status_code}")
print(response.json())
generate_music("a happy children song") |