Spaces:
Paused
Paused
fix bad video file name + only 1 min lyrics time fo faster inference
Browse files
app.py
CHANGED
@@ -36,7 +36,7 @@ compel = Compel(
|
|
36 |
|
37 |
from pydub import AudioSegment
|
38 |
|
39 |
-
def cut_audio(input_path, output_path, max_duration
|
40 |
audio = AudioSegment.from_file(input_path)
|
41 |
|
42 |
if len(audio) > max_duration:
|
@@ -73,6 +73,7 @@ def get_visualizer_video(audio_in, image_in, song_title):
|
|
73 |
title, # str in 'title' Textbox component
|
74 |
audio_in, # str (filepath or URL to file) in 'audio_in' Audio component
|
75 |
image_in, # str (filepath or URL to image) in 'image_in' Image component
|
|
|
76 |
api_name="/predict"
|
77 |
)
|
78 |
|
@@ -81,7 +82,7 @@ def get_visualizer_video(audio_in, image_in, song_title):
|
|
81 |
def infer(audio_file, has_lyrics):
|
82 |
print("NEW INFERENCE ...")
|
83 |
gr.Info('Truncating your audio to the first 30 seconds')
|
84 |
-
truncated_audio = cut_audio(audio_file, "trunc_audio.mp3")
|
85 |
processed_audio = truncated_audio
|
86 |
|
87 |
print("Calling LP Music Caps...")
|
@@ -95,10 +96,12 @@ def infer(audio_file, has_lyrics):
|
|
95 |
if has_lyrics == "Yes" :
|
96 |
print("""βββ
|
97 |
Getting Lyrics ...
|
|
|
98 |
""")
|
|
|
99 |
gr.Info("Getting Lyrics ...")
|
100 |
lyrics_result = lyrics_client.predict(
|
101 |
-
|
102 |
fn_index=0
|
103 |
)
|
104 |
print(f"LYRICS: {lyrics_result}")
|
|
|
36 |
|
37 |
from pydub import AudioSegment
|
38 |
|
39 |
+
def cut_audio(input_path, output_path, max_duration):
|
40 |
audio = AudioSegment.from_file(input_path)
|
41 |
|
42 |
if len(audio) > max_duration:
|
|
|
73 |
title, # str in 'title' Textbox component
|
74 |
audio_in, # str (filepath or URL to file) in 'audio_in' Audio component
|
75 |
image_in, # str (filepath or URL to image) in 'image_in' Image component
|
76 |
+
"my_music_to_image_awesome_video.mp4",
|
77 |
api_name="/predict"
|
78 |
)
|
79 |
|
|
|
82 |
def infer(audio_file, has_lyrics):
|
83 |
print("NEW INFERENCE ...")
|
84 |
gr.Info('Truncating your audio to the first 30 seconds')
|
85 |
+
truncated_audio = cut_audio(audio_file, "trunc_audio.mp3", 30000)
|
86 |
processed_audio = truncated_audio
|
87 |
|
88 |
print("Calling LP Music Caps...")
|
|
|
96 |
if has_lyrics == "Yes" :
|
97 |
print("""βββ
|
98 |
Getting Lyrics ...
|
99 |
+
Note: We only take the first minute of the song
|
100 |
""")
|
101 |
+
truncated_lyrics = cut_audio(audio_file, "trunc_lyrics.mp3", 60000)
|
102 |
gr.Info("Getting Lyrics ...")
|
103 |
lyrics_result = lyrics_client.predict(
|
104 |
+
truncated_lyrics, # str (filepath or URL to file) in 'Song input' Audio component
|
105 |
fn_index=0
|
106 |
)
|
107 |
print(f"LYRICS: {lyrics_result}")
|