Spaces:
Runtime error
Runtime error
HridayKharpude
commited on
Commit
โข
1d9c2aa
1
Parent(s):
600b7eb
Update app.py
Browse files
app.py
CHANGED
@@ -9,22 +9,18 @@ import tensorflow as tf
|
|
9 |
model = tf.keras.models.load_model('TTM_model.h5')
|
10 |
|
11 |
def config_audio(audio):
|
12 |
-
print('enter2')
|
13 |
header = 'ChromaSTFT RMS SpectralCentroid SpectralBandwidth Rolloff ZeroCrossingRate'
|
14 |
for i in range(1, 21):
|
15 |
header += f' mfcc{i}'
|
16 |
header += ' label'
|
17 |
header = header.split()
|
18 |
-
print(1)
|
19 |
file = open('predict_file.csv', 'w', newline='')
|
20 |
with file:
|
21 |
writer = csv.writer(file)
|
22 |
writer.writerow(header)
|
23 |
-
print(2)
|
24 |
#taalfile = audio
|
25 |
#print('stored in taalfile')
|
26 |
y, sr = librosa.load(audio, mono=True, duration=30)
|
27 |
-
print(3)
|
28 |
rms = librosa.feature.rms(y=y)
|
29 |
chroma = librosa.feature.chroma_stft(y=y, sr=sr)
|
30 |
spec_centroid = librosa.feature.spectral_centroid(y=y, sr=sr)
|
@@ -47,11 +43,9 @@ def config_audio(audio):
|
|
47 |
|
48 |
def predict_audio(Audio_Input):
|
49 |
audio=Audio_Input.name
|
50 |
-
print('enter1')
|
51 |
X_predict = config_audio(audio)
|
52 |
taals = ['addhatrital','bhajani','dadra','deepchandi','ektal','jhaptal','rupak','trital']
|
53 |
pred = model.predict(X_predict).flatten()
|
54 |
-
print('exit1')
|
55 |
return {taals[i]: float(pred[i]) for i in range(8)},audio
|
56 |
|
57 |
audio = gr.inputs.Audio(source="upload", optional=False)
|
|
|
9 |
model = tf.keras.models.load_model('TTM_model.h5')
|
10 |
|
11 |
def config_audio(audio):
|
|
|
12 |
header = 'ChromaSTFT RMS SpectralCentroid SpectralBandwidth Rolloff ZeroCrossingRate'
|
13 |
for i in range(1, 21):
|
14 |
header += f' mfcc{i}'
|
15 |
header += ' label'
|
16 |
header = header.split()
|
|
|
17 |
file = open('predict_file.csv', 'w', newline='')
|
18 |
with file:
|
19 |
writer = csv.writer(file)
|
20 |
writer.writerow(header)
|
|
|
21 |
#taalfile = audio
|
22 |
#print('stored in taalfile')
|
23 |
y, sr = librosa.load(audio, mono=True, duration=30)
|
|
|
24 |
rms = librosa.feature.rms(y=y)
|
25 |
chroma = librosa.feature.chroma_stft(y=y, sr=sr)
|
26 |
spec_centroid = librosa.feature.spectral_centroid(y=y, sr=sr)
|
|
|
43 |
|
44 |
def predict_audio(Audio_Input):
|
45 |
audio=Audio_Input.name
|
|
|
46 |
X_predict = config_audio(audio)
|
47 |
taals = ['addhatrital','bhajani','dadra','deepchandi','ektal','jhaptal','rupak','trital']
|
48 |
pred = model.predict(X_predict).flatten()
|
|
|
49 |
return {taals[i]: float(pred[i]) for i in range(8)},audio
|
50 |
|
51 |
audio = gr.inputs.Audio(source="upload", optional=False)
|