-
Notifications
You must be signed in to change notification settings - Fork 1
/
FindU.py
executable file
·69 lines (50 loc) · 1.87 KB
/
FindU.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import os
from pprint import pprint as pp
from youtube_transcript_api import YouTubeTranscriptApi
from QA import load_qa_model, QA_system
from STT import load_stt_model, stt
from Summarization import load_summ_model, summary_script
from wordembedding import *
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
def download_script(id):
transcript = YouTubeTranscriptApi.get_transcripts([id], languages=['ko'])
transcript = transcript[0]
sub = transcript[id]
for x in sub:
x.pop('duration', None)
return sub
if __name__ == "__main__":
i = input("fucntion num: 1(ctrl+F), 2(reliability), 3(STT), 4(association), 5(summarization), 6(QA)")
json_file = download_script('PRlueK97918')
if i == '1':
SearchingValue = input("keyword:")
result_script = ctrl_f(SearchingValue, json_file)
pp(result_script)
if i == '2':
sc_model = load_sc_model()
SearchingValue = input("keyword:")
score = cosin_similar(SearchingValue, json_file, sc_model)
print(score)
if i == '3':
print("Load model...", end='')
stt_model, stt_vocab = load_stt_model()
print("done")
audio_path = 'data/origin_audio/2YD2p24EKb4.wav'
sentences = stt(stt_model, stt_vocab, audio_path)
# pp(sentences[:5])
if i == '4':
wm_model = load_wm_model()
SearchingValue = input("keyword:")
result_script = association_f(SearchingValue, json_file, wm_model)
# pp(result_script)
if i == '5':
summ_model = load_summ_model()
summ_script = summary_script(json_file, summ_model)
pp(summ_script)
if i == '6':
print("Load model...", end='')
qa_model, qa_tokenizer = load_qa_model()
print("done")
question = '이혼한 날'
answers = QA_system(qa_model, qa_tokenizer, question, json_file)
# pp(answers[:5)