root commited on
Commit
48a9e55
·
1 Parent(s): 2c4561e

Initial commit

Browse files
Files changed (1) hide show
  1. emotionanalysis.py +24 -18
emotionanalysis.py CHANGED
@@ -445,21 +445,27 @@ class MusicAnalyzer:
445
  # Create an instance of the analyzer
446
  analyzer = MusicAnalyzer()
447
 
448
- # Analyze the uploaded audio file
449
- results = analyzer.analyze_music(audio_file)
450
-
451
- # Print analysis summary
452
- print("\n=== MUSIC ANALYSIS SUMMARY ===")
453
- print(f"Tempo: {results['summary']['tempo']:.1f} BPM")
454
- print(f"Time Signature: {results['summary']['time_signature']}")
455
- print(f"Key: {results['summary']['key']} {results['summary']['mode']}")
456
- print(f"Primary Emotion: {results['summary']['primary_emotion']}")
457
- print(f"Primary Theme: {results['summary']['primary_theme']}")
458
-
459
- # Show detailed results (optional)
460
- import json
461
- print("\n=== DETAILED ANALYSIS ===")
462
- print(json.dumps(results, indent=2))
463
-
464
- # Visualize the analysis
465
- # analyzer.visualize_analysis(audio_file)
 
 
 
 
 
 
 
445
  # Create an instance of the analyzer
446
  analyzer = MusicAnalyzer()
447
 
448
+ # The following code is for demonstration purposes only
449
+ # and will only run if executed directly (not when imported)
450
+ if __name__ == "__main__":
451
+ # Replace this with a real audio file path when running as a script
452
+ demo_file = "path/to/your/audio/file.mp3"
453
+
454
+ # Analyze the uploaded audio file
455
+ results = analyzer.analyze_music(demo_file)
456
+
457
+ # Print analysis summary
458
+ print("\n=== MUSIC ANALYSIS SUMMARY ===")
459
+ print(f"Tempo: {results['summary']['tempo']:.1f} BPM")
460
+ print(f"Time Signature: {results['summary']['time_signature']}")
461
+ print(f"Key: {results['summary']['key']} {results['summary']['mode']}")
462
+ print(f"Primary Emotion: {results['summary']['primary_emotion']}")
463
+ print(f"Primary Theme: {results['summary']['primary_theme']}")
464
+
465
+ # Show detailed results (optional)
466
+ import json
467
+ print("\n=== DETAILED ANALYSIS ===")
468
+ print(json.dumps(results, indent=2))
469
+
470
+ # Visualize the analysis
471
+ # analyzer.visualize_analysis(demo_file)