Spaces:
Running
Running
File size: 1,193 Bytes
91f3c16 c84f2c4 91f3c16 c84f2c4 91f3c16 c84f2c4 91f3c16 c84f2c4 91f3c16 97eaafb c84f2c4 97eaafb c84f2c4 97eaafb c84f2c4 97eaafb c84f2c4 97eaafb c84f2c4 97eaafb c84f2c4 97eaafb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import librosa
from scripts.predict import predict_multimodal, predict_unimodal
def predict_multimodal_runner(sample: str):
# Load test audio and lyrics
audio_path = f"data/external/{sample}.mp3"
lyrics_path = f"data/external/{sample}.txt"
# Load audio
audio_data, sr = librosa.load(audio_path)
# Load lyrics
with open(lyrics_path, "r", encoding="utf-8") as f:
lyrics_text = f.read()
print("Running multimodal prediction pipeline...")
prediction = predict_multimodal(audio_data, lyrics_text)
print("\n=== MULTIMODAL PREDICTION RESULT ===")
print(f"Prediction: {prediction}")
def predict_unimodal_runner(sample: str):
# Load test audio
audio_path = f"data/external/{sample}.mp3"
# Load audio
audio_data, sr = librosa.load(audio_path)
print("Running audio-only prediction pipeline...")
prediction = predict_unimodal(audio_data)
print("\n=== AUDIO-ONLY PREDICTION RESULT ===")
print(f"Prediction: {prediction}")
if __name__ == "__main__":
sample = "sample"
# Run both predictions
predict_multimodal_runner(sample)
print("\n" + "=" * 50 + "\n")
predict_unimodal_runner(sample)
|