Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,25 +10,18 @@ import os
|
|
| 10 |
import accelerate
|
| 11 |
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
# preprocess and crop audio file
|
| 18 |
-
def audio_preprocess(
|
| 19 |
# separate music and vocal
|
| 20 |
separator = Separator('spleeter:2stems')
|
| 21 |
-
separator.separate_to_file(input_file, output_file)
|
| 22 |
-
|
| 23 |
|
| 24 |
# Crop the audio
|
| 25 |
start_time = 60000 # e.g. 30 seconds, 30000
|
| 26 |
end_time = 110000 # e.g. 40 seconds, 40000
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
audio = AudioSegment.from_file(file_name)
|
| 32 |
cropped_audio = audio[start_time:end_time]
|
| 33 |
processed_audio = cropped_audio
|
| 34 |
# .export('cropped_vocals.wav', format='wav') # save vocal audio file
|
|
@@ -79,12 +72,8 @@ def senti_model(transcription):
|
|
| 79 |
final_result = pipe(transcription)
|
| 80 |
display = f"Sentiment Analysis shows that this song is {final_result[0]['label']}. Confident level of this analysis is {final_result[0]['score']*100:.1f}%."
|
| 81 |
print(display)
|
| 82 |
-
return display
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
# return final_result
|
| 86 |
-
|
| 87 |
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
# main
|
|
|
|
| 10 |
import accelerate
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# preprocess and crop audio file
|
| 14 |
+
def audio_preprocess(input_file):
|
| 15 |
# separate music and vocal
|
| 16 |
separator = Separator('spleeter:2stems')
|
| 17 |
+
#separator.separate_to_file(input_file, output_file)
|
| 18 |
+
separated_audio = separator.separate(input_file)
|
| 19 |
|
| 20 |
# Crop the audio
|
| 21 |
start_time = 60000 # e.g. 30 seconds, 30000
|
| 22 |
end_time = 110000 # e.g. 40 seconds, 40000
|
| 23 |
|
| 24 |
+
audio = AudioSegment.from_file(separated_audio)
|
|
|
|
|
|
|
|
|
|
| 25 |
cropped_audio = audio[start_time:end_time]
|
| 26 |
processed_audio = cropped_audio
|
| 27 |
# .export('cropped_vocals.wav', format='wav') # save vocal audio file
|
|
|
|
| 72 |
final_result = pipe(transcription)
|
| 73 |
display = f"Sentiment Analysis shows that this song is {final_result[0]['label']}. Confident level of this analysis is {final_result[0]['score']*100:.1f}%."
|
| 74 |
print(display)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
+
return display
|
| 77 |
|
| 78 |
|
| 79 |
# main
|