Spaces:
Build error
Build error
app.py
CHANGED
@@ -49,20 +49,18 @@ def get_answers_timestamp(question, final_transcript, transcript):
|
|
49 |
idxmax = lst_scores.index(max(lst_scores))
|
50 |
lst_scores.remove(max(lst_scores))
|
51 |
idxmax2 = lst_scores.index(max(lst_scores))
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
sentence_keyword = answer[:50]
|
56 |
-
|
57 |
dftranscript = pd.DataFrame(transcript)
|
58 |
|
59 |
modelST = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
60 |
embedding_1= modelST.encode(dftranscript.text, convert_to_tensor=True)
|
61 |
-
embedding_2 = modelST.encode(
|
62 |
|
63 |
similarity_tensor = util.pytorch_cos_sim(embedding_1, embedding_2)
|
64 |
idx = torch.argmax(similarity_tensor)
|
65 |
-
start_timestamp = dftranscript.iloc[[int(idx)
|
66 |
start_timestamp = round(start_timestamp)
|
67 |
|
68 |
return start_timestamp
|
|
|
49 |
idxmax = lst_scores.index(max(lst_scores))
|
50 |
lst_scores.remove(max(lst_scores))
|
51 |
idxmax2 = lst_scores.index(max(lst_scores))
|
52 |
+
|
53 |
+
sentence_for_timestamp = lst[idxmax]['answer']
|
54 |
+
|
|
|
|
|
55 |
dftranscript = pd.DataFrame(transcript)
|
56 |
|
57 |
modelST = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
58 |
embedding_1= modelST.encode(dftranscript.text, convert_to_tensor=True)
|
59 |
+
embedding_2 = modelST.encode(sentence_for_timestamp, convert_to_tensor=True)
|
60 |
|
61 |
similarity_tensor = util.pytorch_cos_sim(embedding_1, embedding_2)
|
62 |
idx = torch.argmax(similarity_tensor)
|
63 |
+
start_timestamp = dftranscript.iloc[[int(idx)-1]].start.values[0]
|
64 |
start_timestamp = round(start_timestamp)
|
65 |
|
66 |
return start_timestamp
|