Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,7 @@ 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,7 +112,7 @@ def get_prompts(uploaded_image, track_duration, gen_intensity, gen_mode, openai_
|
|
111 |
|
112 |
prompt = img_to_text(uploaded_image, 'best', 4, fn_index=1)[0]
|
113 |
print(prompt)
|
114 |
-
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:
|
@@ -244,6 +245,13 @@ def convert_mp3_to_wav(mp3_filepath):
|
|
244 |
def remove_emoji(text):
|
245 |
return emoji.get_emoji_regexp().sub(u'', text)
|
246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
article = """
|
249 |
|
|
|
15 |
from os import path
|
16 |
from pydub import AudioSegment
|
17 |
import emoji
|
18 |
+
import re
|
19 |
|
20 |
MUBERT_LICENSE = os.environ.get('MUBERT_LICENSE')
|
21 |
MUBERT_TOKEN = os.environ.get('MUBERT_TOKEN')
|
|
|
112 |
|
113 |
prompt = img_to_text(uploaded_image, 'best', 4, fn_index=1)[0]
|
114 |
print(prompt)
|
115 |
+
prompt = clean_text(prompt)
|
116 |
print(f"prompt cleaned: {prompt}")
|
117 |
musical_prompt = 'You did not use any OpenAI API key to pimp your result :)'
|
118 |
if openai_api_key is not None:
|
|
|
245 |
def remove_emoji(text):
|
246 |
return emoji.get_emoji_regexp().sub(u'', text)
|
247 |
|
248 |
+
def remove_nonalphanumeric(text):
|
249 |
+
return re.sub(r'[^a-zA-Z0-9\s]', '', text)
|
250 |
+
|
251 |
+
def clean_text(text):
|
252 |
+
clean_text = remove_nonalphanumeric(text)
|
253 |
+
clean_text = remove_emoji(clean_text)
|
254 |
+
return clean_text
|
255 |
|
256 |
article = """
|
257 |
|