MusicTherapy / app.py
shallou's picture
Update app.py
a6c6fc6 verified
raw
history blame contribute delete
853 Bytes
import streamlit as st
import requests
# Replace with your actual API URL and key
API_URL = "API_URL = "https://api.musictherapysite.com/v1/generate" # Example URL
API_KEY = "gsk_...zzDm"
# Define Streamlit app layout
st.title("Personalized Healing Songs Generator")
prompt = st.text_area("Enter your emotional or therapeutic needs:")
if st.button("Generate Song"):
if prompt:
headers = {"Authorization": f"Bearer {API_KEY}"}
payload = {"prompt": prompt, "max_length": 150}
response = requests.post(API_URL, headers=headers, json=payload)
if response.status_code == 200:
result = response.json()
st.write(result['generated_text'].strip())
else:
st.error(f"Error: {response.status_code} - {response.text}")
else:
st.error("Please enter a prompt.")