Upload 17 files
Browse files- .gitattributes +10 -0
- Data/upload/user/Blues.wav +3 -0
- Data/upload/user/Classical.wav +3 -0
- Data/upload/user/Country.wav +3 -0
- Data/upload/user/Disco.wav +3 -0
- Data/upload/user/Hiphop.wav +3 -0
- Data/upload/user/Jazz.wav +3 -0
- Data/upload/user/Metal.wav +3 -0
- Data/upload/user/Pop.wav +3 -0
- Data/upload/user/Reggae.wav +3 -0
- Data/upload/user/Rock.wav +3 -0
- Model_APLIKASI_CNN.ipynb +0 -0
- app.py +122 -0
- music-gen-classify-v1.h5/keras_metadata.pb +3 -0
- music-gen-classify-v1.h5/saved_model.pb +3 -0
- music-gen-classify-v1.h5/variables/variables.data-00000-of-00001 +3 -0
- music-gen-classify-v1.h5/variables/variables.index +0 -0
- requirements.txt +6 -0
.gitattributes
CHANGED
@@ -32,3 +32,13 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
Data/upload/user/Blues.wav filter=lfs diff=lfs merge=lfs -text
|
36 |
+
Data/upload/user/Classical.wav filter=lfs diff=lfs merge=lfs -text
|
37 |
+
Data/upload/user/Country.wav filter=lfs diff=lfs merge=lfs -text
|
38 |
+
Data/upload/user/Disco.wav filter=lfs diff=lfs merge=lfs -text
|
39 |
+
Data/upload/user/Hiphop.wav filter=lfs diff=lfs merge=lfs -text
|
40 |
+
Data/upload/user/Jazz.wav filter=lfs diff=lfs merge=lfs -text
|
41 |
+
Data/upload/user/Metal.wav filter=lfs diff=lfs merge=lfs -text
|
42 |
+
Data/upload/user/Pop.wav filter=lfs diff=lfs merge=lfs -text
|
43 |
+
Data/upload/user/Reggae.wav filter=lfs diff=lfs merge=lfs -text
|
44 |
+
Data/upload/user/Rock.wav filter=lfs diff=lfs merge=lfs -text
|
Data/upload/user/Blues.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c9f93bb63ee92491c759fd80f08b63cd9154cb2d7337487caa95d94d0b012f9e
|
3 |
+
size 1323632
|
Data/upload/user/Classical.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b986944b9e535ef1c0aa304e05ed9f4b5b477249894cd8510e2ff54aca007a38
|
3 |
+
size 1323632
|
Data/upload/user/Country.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b3d275b9a0737dbab755e2e043e07d22baab142e5deca7464ad4052ce9c5e9c0
|
3 |
+
size 1323632
|
Data/upload/user/Disco.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3496655d22b1ea1efd55457192b5a78547e71c868dc952dccef883191569804f
|
3 |
+
size 1323052
|
Data/upload/user/Hiphop.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8a71ba0a38a18ad804089b08269a995da06f60307ff13b556ae404dbc312cfac
|
3 |
+
size 1323632
|
Data/upload/user/Jazz.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:37274a42a5a71ca61fb2c8088c1bb071103d7242fea20f7020165903e551de81
|
3 |
+
size 1323632
|
Data/upload/user/Metal.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:052f073c0d370bf38c4ac0bcfd6b277f63aad01dfa11554d53285144f24e453b
|
3 |
+
size 1323052
|
Data/upload/user/Pop.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25c4d6b576269fb94307da6dca93664dca4c7d9aaabbfd9e8269ac8696c4a595
|
3 |
+
size 1323052
|
Data/upload/user/Reggae.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d2d74b107a012767695bd3a2e2f5d4928fb978ed329276b4c32a5b5847eb79ba
|
3 |
+
size 1323052
|
Data/upload/user/Rock.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:aa7536977b3d58258a4bd84757a0eb30b0113d7171ac36134c5f1cddacedee15
|
3 |
+
size 1323632
|
Model_APLIKASI_CNN.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
app.py
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import librosa
|
3 |
+
import math
|
4 |
+
from tensorflow import keras
|
5 |
+
import streamlit as st
|
6 |
+
import time
|
7 |
+
import pyautogui
|
8 |
+
|
9 |
+
def get_mfcc(audio_signal, num_mfcc=13, n_fft=2048, hop_length=512, num_segments=5):
|
10 |
+
new_data = {
|
11 |
+
"mfcc": []
|
12 |
+
}
|
13 |
+
|
14 |
+
SAMPLE_RATE = 22050
|
15 |
+
signal,sample_rate = librosa.load(audio_signal,sr = SAMPLE_RATE)
|
16 |
+
TRACK_DURATION = int(librosa.get_duration(signal)) # measured in seconds
|
17 |
+
SAMPLES_PER_TRACK = SAMPLE_RATE * TRACK_DURATION
|
18 |
+
samples_per_segment = int(SAMPLES_PER_TRACK / num_segments)
|
19 |
+
num_mfcc_vectors_per_segment = math.ceil(samples_per_segment / hop_length)
|
20 |
+
|
21 |
+
for d in range(num_segments):
|
22 |
+
|
23 |
+
start = samples_per_segment * d
|
24 |
+
finish = start + samples_per_segment
|
25 |
+
|
26 |
+
mfcc = librosa.feature.mfcc(signal[start:finish], sample_rate, n_mfcc=num_mfcc, n_fft=n_fft, hop_length=hop_length)
|
27 |
+
mfcc = mfcc.T
|
28 |
+
|
29 |
+
if len(mfcc) == num_mfcc_vectors_per_segment:
|
30 |
+
new_data["mfcc"].append(mfcc.tolist())
|
31 |
+
|
32 |
+
return new_data["mfcc"]
|
33 |
+
|
34 |
+
def prediction(mfcc):
|
35 |
+
|
36 |
+
cnn_model = keras.models.load_model('music-gen-classify-v1.h5')
|
37 |
+
mfcc = np.array(mfcc)
|
38 |
+
mfcc = mfcc[...,np.newaxis]
|
39 |
+
prediction = cnn_model.predict(mfcc)
|
40 |
+
return max(np.argmax(prediction,axis = 1))
|
41 |
+
|
42 |
+
def get_genre(prediction):
|
43 |
+
|
44 |
+
pred = ''
|
45 |
+
if prediction == 0:
|
46 |
+
pred = 'Blues'
|
47 |
+
|
48 |
+
elif prediction == 1:
|
49 |
+
pred = 'Classical'
|
50 |
+
|
51 |
+
elif prediction == 2:
|
52 |
+
pred = 'Country'
|
53 |
+
|
54 |
+
elif prediction == 3:
|
55 |
+
pred = 'Disco'
|
56 |
+
|
57 |
+
elif prediction == 4:
|
58 |
+
pred = 'Hip Hop'
|
59 |
+
|
60 |
+
elif prediction == 5:
|
61 |
+
pred = 'Jazz'
|
62 |
+
|
63 |
+
elif prediction == 6:
|
64 |
+
pred = 'Metal'
|
65 |
+
|
66 |
+
elif prediction == 7:
|
67 |
+
pred = 'Pop'
|
68 |
+
|
69 |
+
elif prediction == 8:
|
70 |
+
pred = 'Reggae'
|
71 |
+
|
72 |
+
elif prediction == 9:
|
73 |
+
pred = 'Rock'
|
74 |
+
|
75 |
+
return pred
|
76 |
+
|
77 |
+
|
78 |
+
def main():
|
79 |
+
|
80 |
+
st.set_page_config(layout='wide',page_title='Klasifikasi Genre Musik',page_icon='π΅')
|
81 |
+
st.title('Prediksi Genre Musik')
|
82 |
+
st.markdown('Website ini bisa memprediksi hingga 10 genre yaitu Blues, Classical, Country, Disco, Hiphop,Jazz, Metal, Pop, Reggae, dan Rock. Tentu prediksi genre ini tidak selalu tepat karena lagu itu multi genre, tapi selamat mencoba!')
|
83 |
+
selected_item = st.selectbox('Pilih Sample Musik Atau Upload Musikmu !',['Sample Musik','Upload'])
|
84 |
+
|
85 |
+
if selected_item is not None:
|
86 |
+
if selected_item == 'Upload':
|
87 |
+
files = st.file_uploader('Format Musik ".wav" berdurasi maksimal 30sec', type='wav', accept_multiple_files=False)
|
88 |
+
|
89 |
+
if files is not None:
|
90 |
+
audio,sr = librosa.load(files,sr = 22050)
|
91 |
+
duration = int(librosa.get_duration(audio))
|
92 |
+
if 'file_uploaded' not in st.session_state:
|
93 |
+
st.session_state['file_uploaded'] = True
|
94 |
+
|
95 |
+
for percent_complete in range(100):
|
96 |
+
time.sleep(0.01)
|
97 |
+
bar.progress(i+1)
|
98 |
+
i = i+1
|
99 |
+
pyautogui.hotkey('ctrl', 'F5')
|
100 |
+
|
101 |
+
elif st.session_state['file_uploaded'] == True:
|
102 |
+
st.audio(files, format="audio/wav", start_time=0)
|
103 |
+
|
104 |
+
|
105 |
+
elif selected_item == 'Sample Musik':
|
106 |
+
selected_file = st.selectbox("Pilih Sample", ['Blues','Jazz','Country','Classical','Hiphop','Metal','Pop','Reggae','Rock'])
|
107 |
+
files = f'Data/upload/user/{selected_file}.wav'
|
108 |
+
st.audio(files, format="audio/wav", start_time=0)
|
109 |
+
submitted = st.button("Prediksi")
|
110 |
+
|
111 |
+
if submitted:
|
112 |
+
with st.spinner('Tunggu Sebentar'):
|
113 |
+
signal = files
|
114 |
+
mfcc_for_track = get_mfcc(signal)
|
115 |
+
|
116 |
+
predict = prediction(mfcc_for_track)
|
117 |
+
genre = get_genre(int(predict))
|
118 |
+
st.success('Proses Prediksi Selesai!')
|
119 |
+
st.markdown(f'Genre Musikmu adalah π΅ : Musik **{genre}** ')
|
120 |
+
|
121 |
+
if __name__ == '__main__':
|
122 |
+
main()
|
music-gen-classify-v1.h5/keras_metadata.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:92ac5355875bc5d4a98221f6920648dd683d945a3d2728d521fbca6dd1758424
|
3 |
+
size 32533
|
music-gen-classify-v1.h5/saved_model.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1372ce4e349ad0e1c18559d5ea6d996cac17de7f67c3eb35eedb332ed4aff7f1
|
3 |
+
size 357033
|
music-gen-classify-v1.h5/variables/variables.data-00000-of-00001
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4e0a890fb2a58d6b76902f1b720c62d1a335e0a08854004ccaf4c087a8edce83
|
3 |
+
size 3950842
|
music-gen-classify-v1.h5/variables/variables.index
ADDED
Binary file (4.98 kB). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit==0.68.1
|
2 |
+
pandas==0.25.3
|
3 |
+
pyautogui==0.9.53
|
4 |
+
tensorflow==2.11.0
|
5 |
+
librosa==0.9.2
|
6 |
+
SoundFile
|