fffiloni commited on
Commit
a779e8d
โ€ข
1 Parent(s): 7019983

Remove any unwanted emojis in prompts

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -14,6 +14,7 @@ import urllib
14
  import pydub
15
  from os import path
16
  from pydub import AudioSegment
 
17
 
18
  MUBERT_LICENSE = os.environ.get('MUBERT_LICENSE')
19
  MUBERT_TOKEN = os.environ.get('MUBERT_TOKEN')
@@ -110,12 +111,14 @@ def get_prompts(uploaded_image, track_duration, gen_intensity, gen_mode, openai_
110
 
111
  prompt = img_to_text(uploaded_image, 'best', 4, fn_index=1)[0]
112
  print(prompt)
 
 
113
  musical_prompt = 'You did not use any OpenAI API key to pimp your result :)'
114
  if openai_api_key is not None:
115
  gpt_adaptation = try_api(prompt, openai_api_key)
116
  if gpt_adaptation[0] != "oups":
117
  musical_prompt = gpt_adaptation[0]
118
- print(f"misical adapt: {musical_prompt}")
119
  music_result = get_results(musical_prompt, track_duration, gen_intensity, gen_mode)
120
  else:
121
  music_result = get_results(prompt, track_duration, gen_intensity, gen_mode)
@@ -238,6 +241,10 @@ def convert_mp3_to_wav(mp3_filepath):
238
 
239
  return wave_file
240
 
 
 
 
 
241
  article = """
242
 
243
  <div class="footer">
 
14
  import pydub
15
  from os import path
16
  from pydub import AudioSegment
17
+ import emoji
18
 
19
  MUBERT_LICENSE = os.environ.get('MUBERT_LICENSE')
20
  MUBERT_TOKEN = os.environ.get('MUBERT_TOKEN')
 
111
 
112
  prompt = img_to_text(uploaded_image, 'best', 4, fn_index=1)[0]
113
  print(prompt)
114
+ prompt = remove_emoji(prompt)
115
+ print(f"prompt cleaned: {prompt}")
116
  musical_prompt = 'You did not use any OpenAI API key to pimp your result :)'
117
  if openai_api_key is not None:
118
  gpt_adaptation = try_api(prompt, openai_api_key)
119
  if gpt_adaptation[0] != "oups":
120
  musical_prompt = gpt_adaptation[0]
121
+ print(f"musical adapt: {musical_prompt}")
122
  music_result = get_results(musical_prompt, track_duration, gen_intensity, gen_mode)
123
  else:
124
  music_result = get_results(prompt, track_duration, gen_intensity, gen_mode)
 
241
 
242
  return wave_file
243
 
244
+ def remove_emoji(text):
245
+ return emoji.get_emoji_regexp().sub(u'', text)
246
+
247
+
248
  article = """
249
 
250
  <div class="footer">