Skip to content

Commit 599a25e

Browse files
Create Audio Summarizer
1 parent b024970 commit 599a25e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Audio Summarizer

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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()

0 commit comments

Comments
 (0)