Spaces:
Runtime error
Runtime error
Commit Β·
7761659
1
Parent(s): 365609b
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,22 +52,31 @@ def process_file(input_path):
|
|
| 52 |
return process(input_path, '')
|
| 53 |
|
| 54 |
def process(audio_file, embed_html_all):
|
| 55 |
-
model = openl3.models.load_audio_embedding_model(input_repr="linear", content_type="music",embedding_size=512)
|
| 56 |
-
audio, sr = librosa.load(audio_file, mono=True)
|
| 57 |
-
emb, ts = openl3.get_audio_embedding(audio, sr, model=model)
|
| 58 |
-
emb = np.mean(emb, axis=0)
|
| 59 |
-
print("SHAPE ", emb.shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
D, I =
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
return top1, top2, top3, top4, top5
|
| 73 |
|
|
|
|
| 52 |
return process(input_path, '')
|
| 53 |
|
| 54 |
def process(audio_file, embed_html_all):
|
| 55 |
+
#model = openl3.models.load_audio_embedding_model(input_repr="linear", content_type="music",embedding_size=512)
|
| 56 |
+
#audio, sr = librosa.load(audio_file, mono=True)
|
| 57 |
+
#emb, ts = openl3.get_audio_embedding(audio, sr, model=model)
|
| 58 |
+
#emb = np.mean(emb, axis=0)
|
| 59 |
+
#print("SHAPE ", emb.shape)
|
| 60 |
+
|
| 61 |
+
emb, ts = get_embed(audio_file)
|
| 62 |
+
|
| 63 |
+
#ind = faiss.read_index("index.index")
|
| 64 |
+
#ind_filenames = pickle.load(open('index.filenames','rb'))
|
| 65 |
+
ind, ind_filenames = load_index()
|
| 66 |
|
| 67 |
+
#dict_bmg = pickle.load(open('dict_bmg.pickle','rb')) # filename to url
|
| 68 |
+
catalog = load_catalog()
|
| 69 |
+
|
| 70 |
+
D, I = do_search(embed, ind)
|
| 71 |
+
#D, I = ind.search(emb.reshape((1,512)), 5)
|
| 72 |
+
|
| 73 |
+
#top1 = dict_bmg[ind_filenames[I[0][0]]]
|
| 74 |
+
#top2 = dict_bmg[ind_filenames[I[0][1]]]
|
| 75 |
+
#top3 = dict_bmg[ind_filenames[I[0][2]]]
|
| 76 |
+
#top4 = dict_bmg[ind_filenames[I[0][3]]]
|
| 77 |
+
#top5 = dict_bmg[ind_filenames[I[0][4]]]
|
| 78 |
+
|
| 79 |
+
top1, top2, top3, top4, top5 = get_top(I, ind_filenames, catalog)
|
| 80 |
|
| 81 |
return top1, top2, top3, top4, top5
|
| 82 |
|