|
import os |
|
import sys |
|
from app import process_audio, music_analyzer |
|
|
|
def main(): |
|
""" |
|
Example function to demonstrate the application with a sample audio file. |
|
|
|
Usage: |
|
python example.py <path_to_audio_file> |
|
""" |
|
if len(sys.argv) != 2: |
|
print("Usage: python example.py <path_to_audio_file>") |
|
return |
|
|
|
audio_file = sys.argv[1] |
|
if not os.path.exists(audio_file): |
|
print(f"Error: File {audio_file} does not exist.") |
|
return |
|
|
|
print(f"Processing audio file: {audio_file}") |
|
|
|
|
|
genre_results, lyrics = process_audio(audio_file) |
|
|
|
|
|
emotion_results = music_analyzer.analyze_music(audio_file) |
|
|
|
|
|
print("\n" + "="*50) |
|
print("GENRE CLASSIFICATION RESULTS:") |
|
print("="*50) |
|
print(genre_results) |
|
|
|
print("\n" + "="*50) |
|
print("EMOTION ANALYSIS RESULTS:") |
|
print("="*50) |
|
print(f"Tempo: {emotion_results['summary']['tempo']:.1f} BPM") |
|
print(f"Key: {emotion_results['summary']['key']} {emotion_results['summary']['mode']}") |
|
print(f"Primary Emotion: {emotion_results['summary']['primary_emotion']}") |
|
print(f"Primary Theme: {emotion_results['summary']['primary_theme']}") |
|
|
|
print("\n" + "="*50) |
|
print("GENERATED LYRICS:") |
|
print("="*50) |
|
print(lyrics) |
|
|
|
if __name__ == "__main__": |
|
main() |