-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
58 lines (49 loc) · 1.65 KB
/
main.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
import argparse
from Utils import Config
from Settings import *
from AudioToText import audio_to_text
from Youtube import download_audios
from VectorDb import setup_vector_db
from Rag import rag_chain
from ChatInterface import launch_chat_interface
def setup():
return Config(
temp_dir=TEMP_DIR,
whisper_model=WHISPER_MODEL,
embedding_model = EMBEDDING_MODEL,
vector_db_name = VECTOR_DB_NAME,
document_split_options = DOCUMENT_SPLIT_OPTIONS,
llm_model = LLM_MODEL,
chat_memory = CHAT_MEMORY,
share_chat_interface = SHARE_CHAT_INTERFACE
)
def main( urls ):
try:
config = setup()
audio_files = download_audios(urls, config)
transcribed_files = audio_to_text(audio_files, config)
vector_store = setup_vector_db(transcribed_files, config)
rag = rag_chain(vector_store, config)
launch_chat_interface(rag, config)
except KeyboardInterrupt as e:
print("Exiting...")
except Exception as e:
print(e)
finally:
config.close()
return
def parese_arguments():
parser = argparse.ArgumentParser(description="Chat With Youtube Videos")
parser.add_argument(
'urls',
metavar='URLS',
type=str,
nargs='+',
help='Provide one or more YouTube video URLs in the format: https://www.youtube.com/watch?v=<VideoId>'
)
args = parser.parse_args()
return args.urls
if __name__ == "__main__":
# The url must be of this format: https://www.youtube.com/watch?v=<VideoId>
urls = parese_arguments()
main( urls )