MarfinF commited on
Commit
dda6bdd
ยท
1 Parent(s): cb23c4c

- add song genre and delete folder music & adjust docker

Browse files
Dockerfile CHANGED
@@ -15,7 +15,6 @@ RUN python -c "from transformers import pipeline; pipeline('zero-shot-classifica
15
 
16
  COPY . .
17
  COPY frontend ./frontend
18
- COPY music ./music
19
 
20
  EXPOSE 7860
21
 
 
15
 
16
  COPY . .
17
  COPY frontend ./frontend
 
18
 
19
  EXPOSE 7860
20
 
backend/app.py CHANGED
@@ -58,6 +58,15 @@ mood_to_genre = {
58
  "chill": "chill"
59
  }
60
 
 
 
 
 
 
 
 
 
 
61
  # ๐Ÿ”น Detect Emotion
62
  def detect_emotion(text):
63
  labels = ["takut", "marah", "sedih", "senang", "cinta"]
@@ -69,17 +78,9 @@ def detect_emotion(text):
69
  # ๐Ÿ”น Get Music Recommendations
70
  def get_recommendations_by_mood(mood):
71
  genre_folder = mood_to_genre.get(mood, "pop")
72
- folder_path = f"music/{genre_folder}"
73
- print("folder path")
74
- print(folder_path)
75
-
76
- # Check if folder exists
77
- if not os.path.exists(folder_path):
78
- return []
79
- print("folder exist")
80
 
81
  # List and shuffle songs
82
- songs = [f"music/{genre_folder}/{song}" for song in os.listdir(folder_path) if song.endswith(".mp3")]
83
  random.shuffle(songs)
84
  return songs[:3] # Return top 3 shuffled songs
85
 
 
58
  "chill": "chill"
59
  }
60
 
61
+ genre_to_song = {
62
+ "pop": ["https://sounds.pond5.com/inspirational-motivational-uplifting-acoustic-positive-music-102770115_nw_prev.m4a"],
63
+ "acoustic": ["https://sounds.pond5.com/sad-piano-music-063450274_nw_prev.m4a"],
64
+ "rock": ["https://sounds.pond5.com/powerful-gritty-action-extreme-rock-music-136693652_nw_prev.m4a"],
65
+ "intense": ["https://sounds.pond5.com/epic-action-hybrid-trailer-instrum-music-072727124_nw_prev.m4a"],
66
+ "romantic": ["https://sounds.pond5.com/bloom-sweet-tender-delicate-romantic-music-158563013_nw_prev.m4a"],
67
+ "chill": ["https://sounds.pond5.com/fall-chill-music-088328584_nw_prev.m4a"]
68
+ }
69
+
70
  # ๐Ÿ”น Detect Emotion
71
  def detect_emotion(text):
72
  labels = ["takut", "marah", "sedih", "senang", "cinta"]
 
78
  # ๐Ÿ”น Get Music Recommendations
79
  def get_recommendations_by_mood(mood):
80
  genre_folder = mood_to_genre.get(mood, "pop")
81
+ songs = genre_to_song.get(genre_folder, [])
 
 
 
 
 
 
 
82
 
83
  # List and shuffle songs
 
84
  random.shuffle(songs)
85
  return songs[:3] # Return top 3 shuffled songs
86
 
music/acoustic/acoustic_1.mp3 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:1b0d991dc0de67a019454c9bde13eacd4fd1f99ec6c6b508695e22d7b577bd51
3
- size 3037905
 
 
 
 
music/chill/chill_1.mp3 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2503caeb3d2bf5638e470cfe44b94ced7388a1a33756b2340b81312a464edbfb
3
- size 3140914
 
 
 
 
music/cinematic/cinematic_1.mp3 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c60f6ffcadbb09a877ec847ddc862d46ca25c75931bb3a94867d56e4d2693d18
3
- size 2494090
 
 
 
 
music/pop/pop_1.mp3 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c9853ed097444464faa98514808a71758b953d1364908f31e338ca30835c5639
3
- size 2169793
 
 
 
 
music/rnb/romantic_1.mp3 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:df910b550af4c3b9dd079f2188a32e9af7f90557b2ec974678dafaeeb373d6a3
3
- size 4251009
 
 
 
 
music/rock/rock_1.mp3 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:490400383d49441fce99c71febcc85c454ff583911ad8d331a8259f81be94612
3
- size 3162531