-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
57 lines (46 loc) · 1.74 KB
/
main.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# main.py
import streamlit as st
from fastapi import FastAPI
from pydantic import BaseModel
import uvicorn
import generate_adu
from PIL import Image # Importing the generate_audio module
# Define a request model for FastAPI
class TextPrompt(BaseModel):
prompt: str
app = FastAPI()
@app.post("/generate-audio/")
async def generate_audio_endpoint(prompt: TextPrompt):
result = generate_adu.generate(prompt.prompt)
return {"audio": result.getvalue()} # Return binary content for the audio file
def run_fastapi():
uvicorn.run(app, host="0.0.0.0", port=8000)
def run_streamlit():
# Load and display logo
logo = Image.open("Music_logo.png")
# Display logo and title
st.image(logo, width=80, use_column_width=False)
st.title("Sangeet Guru")
st.subheader("Input Your Style, Get Your Music")
prompt = st.text_input("Enter your music style:")
if st.button("Generate"):
audio_io = generate_adu.generate(prompt)
st.audio(audio_io, format='audio/wav')
# Example prompts
st.markdown("### Examples:")
examples = [
"80s pop track with bassy drums and synth",
"Earthy tones, environmentally conscious, ukulele-infused",
"90s rock song with loud guitars and heavy drums",
"Heartful EDM with beautiful synths and chords",
"Classical Indian raga with sitar and tabla"
]
for example in examples:
if st.button(example):
audio_io = generate_adu.generate(example)
st.audio(audio_io, format='audio/wav')
if __name__ == "__main__":
# Uncomment the following line to run FastAPI
# run_fastapi()
# Uncomment the following line to run Streamlit
run_streamlit()