fffiloni commited on
Commit
9021561
โ€ข
1 Parent(s): ffa3b72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -12
app.py CHANGED
@@ -118,7 +118,7 @@ def get_prompts(uploaded_image, track_duration, gen_intensity, gen_mode, openai_
118
  musical_prompt = prompt
119
  music_result = get_results(musical_prompt, track_duration, gen_intensity, gen_mode)
120
 
121
- wave_file = convert_mp3_to_wav("sample.mp3")
122
 
123
  time.sleep(1)
124
  return wave_file, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
@@ -159,7 +159,7 @@ def try_api(message, openai_api_key):
159
 
160
  def call_api(message, openai_api_key):
161
 
162
- instruction = "Convert this image description in a very concise way with musical terms, as if you wanted to describe a music that would fit this image, with less than 200 characters"
163
 
164
  print("starting open ai")
165
  augmented_prompt = f"{instruction}: '{message}'."
@@ -220,18 +220,9 @@ def generate_track_by_prompt(pat, prompt, duration, gen_intensity, gen_mode):
220
 
221
  def convert_mp3_to_wav(mp3_filepath):
222
 
223
- url = mp3_filepath
224
- save_as = "file.mp3"
225
-
226
- data = urllib.request.urlopen(url)
227
-
228
- f = open(save_as,'wb')
229
- f.write(data.read())
230
- f.close()
231
-
232
  wave_file="file.wav"
233
 
234
- sound = AudioSegment.from_mp3(save_as)
235
  sound.export(wave_file, format="wav")
236
 
237
  return wave_file
 
118
  musical_prompt = prompt
119
  music_result = get_results(musical_prompt, track_duration, gen_intensity, gen_mode)
120
 
121
+ wave_file = convert_mp3_to_wav(music_result)
122
 
123
  time.sleep(1)
124
  return wave_file, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
 
159
 
160
  def call_api(message, openai_api_key):
161
 
162
+ instruction = "Convert in less than 200 characters this image caption to a very concise musical description with musical terms, as if you wanted to describe a musical ambiance"
163
 
164
  print("starting open ai")
165
  augmented_prompt = f"{instruction}: '{message}'."
 
220
 
221
  def convert_mp3_to_wav(mp3_filepath):
222
 
 
 
 
 
 
 
 
 
 
223
  wave_file="file.wav"
224
 
225
+ sound = mp3_filepath
226
  sound.export(wave_file, format="wav")
227
 
228
  return wave_file