File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ from langchain_community.vectorstores import Chroma
2
+ from langchain_ollama import OllamaEmbeddings
3
+ from paddleocr import PaddleOCR
4
+ import whisper
5
+
6
+ def transcript_generator():
7
+ model = whisper.load_model("base")
8
+
9
+ result = model.transcribe("audio.mp4")
10
+ provide_summarizer(result)
11
+
12
+
13
+ def provide_summarizer(Text):
14
+ import re
15
+
16
+ import openai
17
+ openai.api_key="Enter Api Key"
18
+ openai.api_base = "https://api.groq.com/openai/v1"
19
+
20
+ text_to_summarize = Text["text"]
21
+
22
+ response = openai.ChatCompletion.create(
23
+ model="llama3-8b-8192",
24
+ messages=[
25
+ {"role": "system", "content": "You are a helpful assistant who summarizes long text into points."},
26
+ {"role": "user", "content": f"Summarize the following:\n\n{text_to_summarize}"}
27
+ ]
28
+ )
29
+
30
+ summary = re.split(r"(?<=[!?]) +",response["choices"][0]["message"]["content"])
31
+
32
+ with open("summary.txt", "w+") as file:
33
+ for sentence in summary:
34
+ file.write(sentence.strip() + "\n")
35
+ file.close()
36
+
37
+
38
+ if __name__ == "__main__":
39
+ transcript_generator()
You can’t perform that action at this time.
0 commit comments