pn23 commited on
Commit
9e83e84
·
verified ·
1 Parent(s): 9e5bc96

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -16
app.py CHANGED
@@ -13,8 +13,19 @@ import os
13
  # VIDEO_URL = "https://example.com/not-youtube.mp4"
14
  # st.video(VIDEO_URL)
15
 
16
-
17
-
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  # print(str(title))
20
  # print(lyrics)
@@ -42,35 +53,35 @@ def init_model(user_input):
42
  model = genai.GenerativeModel('gemini-pro')
43
 
44
  userInput = user_input #"Give me an afrofunk beat along with a cool melody and catchy drums, along with an opera style"
45
- prompt = userInput + ". Output ONLY the specific music genre that the user would like that fits their requirements, with no excess words. Simply the genre, NO APOSTROPHES. If required, add more than one genre to best fit the user's prompt by adding a comma and space and a another genre. Desired Output: <all_lowercase_comma_separated_genres>"
46
  response = model.generate_content(prompt)
47
  genre = response.text
48
 
49
- userInput = "Genre: " + genre + ". Generate lyrics that would best fit into the required genre. The lyrics should not be about the genre, but would best fit into the genre. Generate around 1 minutes worth of lyrics. Separate verses using [Verse #] and NO APOSTROPHES AT ALL. If you must use them, please remove them from the word, even if it mispells the word. Desired Format: <seperate_each_verse_no_asteriks_or_apostrophes>"
50
  response = model.generate_content(userInput)
51
  lyrics = response.text
52
 
53
- lyricInput = "Lyrics: " + lyrics + ". Based upon the following lyrics, please generate a title for this song. Desired Format: <title_case_without_genre>"
54
  response = model.generate_content(lyricInput)
55
  title = response.text
56
 
57
- userInput = "Lyrics: " + lyrics + ". Split the following lyrics into ONLY 10 slices with each slice enhanced to describe a music video. You may slightlly alter the lyrics to best cater to this requirment. Each section is separated by a |. Use only 10 |'s. Delete ALL \n characters and Verse seperators as well. Desired Output: <|_separated>"
58
- response = model.generate_content(userInput)
59
- sepTen = response.text
60
- whollySplit = sepTen.split("|")
61
 
62
- Add code for list of frame
63
- call separate script for frame generation
64
- gen_movie(whollySplit[:10])
65
 
 
 
66
  #make API request
 
67
 
68
-
69
 
70
  #call webscraping script
71
  #get_mp3("Samba Kickoff")
72
 
73
- return genre
74
 
75
  #st_callback = StreamlitCallbackHandler(st.container())
76
 
@@ -84,11 +95,13 @@ if prompt := st.chat_input():
84
  if init_alr == False:
85
  init_alr = True
86
 
87
- genre = init_model(prompt)
88
  #Call query generator with text_input
89
  #query = prompty(date_input, prompt)
90
  #result = qa({"query": query})
91
 
92
  st.write('Based on the interesting description you have provided, we will generate a ' + genre + ' music experience for you:')
93
- st.video('combined_video.mp4')
 
 
94
  st.stop()
 
13
  # VIDEO_URL = "https://example.com/not-youtube.mp4"
14
  # st.video(VIDEO_URL)
15
 
16
+ def getSongUrl(title):
17
+   url = "https://mothersuno-api.vercel.app/api/get?id"
18
+   response = requests.get(url)
19
+   response.json()
20
+   for i in range(len(response.json())):
21
+     if (response.json()[i]['title'] == title):
22
+       return response.json()[i]['audio_url']
23
+
24
+ def generate_audio(lyrics, genre, title):
25
+   url = "https://mothersuno-api.vercel.app/api/custom_generate"
26
+   payload = {"prompt": lyrics, "tags" : genre, "title" : str(title), "make_instrumental": False, "wait_audio": False}
27
+   response = requests.post(url,json=payload)
28
+   return response.text
29
 
30
  # print(str(title))
31
  # print(lyrics)
 
53
  model = genai.GenerativeModel('gemini-pro')
54
 
55
  userInput = user_input #"Give me an afrofunk beat along with a cool melody and catchy drums, along with an opera style"
56
+ prompt = userInput + ". Output ONLY the specific music genre that the user would like that fits their requirements, with no excess words. NO APOSTROPHES. Add more than one genre to best fit the user's prompt. Desired Output: <all_lowercase_comma_separated_genres>"
57
  response = model.generate_content(prompt)
58
  genre = response.text
59
 
60
+ userInput = "Genre: " + genre + ". Generate lyrics that would best fit into the required genre. Generate around 2 minutes worth of lyrics. Separate verses using [Verse #] and NO APOSTROPHES AT ALL. Desired Format: <seperate_each_verse_no_asteriks_or_apostrophes>"
61
  response = model.generate_content(userInput)
62
  lyrics = response.text
63
 
64
+ lyricInput = "Lyrics: " + lyrics[:25] + ". Based upon the following lyrics, please generate a title for this song. Desired Format: <title_case_without_genre>"
65
  response = model.generate_content(lyricInput)
66
  title = response.text
67
 
68
+ # userInput = "Lyrics: " + lyrics + ". Split the following lyrics into ONLY 10 slices with each slice enhanced to describe a music video. You may slightlly alter the lyrics to best cater to this requirment. Each section is separated by a |. Use only 10 |'s. Delete ALL \n characters and Verse seperators as well. Desired Output: <|_separated>"
69
+ # response = model.generate_content(userInput)
70
+ # sepTen = response.text
71
+ # whollySplit = sepTen.split("|")
72
 
 
 
 
73
 
74
+ #generate_audio(lyrics, genre, title)
75
+
76
  #make API request
77
+ #audiourl = getSongUrl(title)
78
 
79
+ audiourl = "google.com"
80
 
81
  #call webscraping script
82
  #get_mp3("Samba Kickoff")
83
 
84
+ return title, genre, lyrics, audiourl
85
 
86
  #st_callback = StreamlitCallbackHandler(st.container())
87
 
 
95
  if init_alr == False:
96
  init_alr = True
97
 
98
+ title, genre, lyrics, audiourl = init_model(prompt)
99
  #Call query generator with text_input
100
  #query = prompty(date_input, prompt)
101
  #result = qa({"query": query})
102
 
103
  st.write('Based on the interesting description you have provided, we will generate a ' + genre + ' music experience for you:')
104
+ st.write('Title: ' + title)
105
+ st.write('Lyrics: ' + lyrics)
106
+ st.write('You can find the final generated audio file here: ' + audiourl)
107
  st.stop()