root
commited on
Commit
·
48a9e55
1
Parent(s):
2c4561e
Initial commit
Browse files- 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 |
-
#
|
449 |
-
|
450 |
-
|
451 |
-
#
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
print("
|
462 |
-
print(
|
463 |
-
|
464 |
-
|
465 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|