shauryat97 commited on
Commit
709ae5f
·
1 Parent(s): 1378320

Added Our code

Browse files
Files changed (1) hide show
  1. app.py +53 -4
app.py CHANGED
@@ -1,7 +1,56 @@
1
  import gradio as gr
2
  from main_query_tube import *
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from main_query_tube import *
3
+ from thirdai import licensing, neural_db as ndb
4
+ licensing.deactivate()
5
+ licensing.activate("1FB7DD-CAC3EC-832A67-84208D-C4E39E-V3")
6
 
7
+ def search_playlist(playlist_link, query):
8
+ csv_file = create_data(playlist_link)
9
+ csv_file['index_col'] = csv_file.index
10
+ csv_file.iloc[:, 1:4] = csv_file.iloc[:, 1:4].astype(str)
11
+ db = ndb.NeuralDB(user_id="team_iisc_query_tube")
12
+ insertable_docs = []
13
+
14
+ for file in csv_file:
15
+ csv_doc = ndb.CSV(
16
+ path=file,
17
+ id_column="index_col",
18
+ strong_columns=["text"],
19
+ weak_columns=[],
20
+ reference_columns=["text"],
21
+ save_extra_info=True)
22
+ insertable_docs.append(csv_doc)
23
+ source_ids = db.insert(insertable_docs, train=True)
24
+ search_results = db.search(
25
+ query=query,
26
+ top_k=3,
27
+ on_error=lambda error_msg: print(f"Error! {error_msg}"))
28
+
29
+ for result in search_results:
30
+ return result.metadata['video_serial_number'][0]
31
+ # print(result.text)
32
+ # print(result.context(radius=1))
33
+ # print(result.source)
34
+ # print('video_number = ',result.metadata['video_serial_number'])
35
+ # print('start_time =',result.metadata['start'])
36
+ # print('************')
37
+
38
+
39
+
40
+
41
+ # def greet(name):
42
+ # return "Hello " + name + "!!"
43
+
44
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
45
+ # iface.launch()
46
+
47
+ iface = gr.Interface(
48
+ fn=search_playlist,
49
+ inputs=[gr.inputs.Textbox(label="YouTube Playlist Link"),
50
+ gr.inputs.Textbox(label="Query")],
51
+ outputs=[gr.outputs.Dataframe(columns=['video_number', 'video_title'])],
52
+ title="YouTube Playlist Search",
53
+ description="Enter a YouTube playlist link and a query to find videos where the query is discussed."
54
+ )
55
+
56
+ iface.launch()