MCPcopy Index your code
hub / github.com/geekcomputers/Python / provide_summarizer

Function provide_summarizer

Audio_Summarizer.py:18–51  ·  view source on GitHub ↗
(Text)

Source from the content-addressed store, hash-verified

16
17
18def provide_summarizer(Text):
19 # Set up Groq OpenAI-compatible API credentials
20 openai.api_key = os.getenv(
21 "OPENAI_API_KEY", "your-api-key-here"
22 ) # Replace or set in environment
23 openai.api_base = "https://api.groq.com/openai/v1"
24
25 # Extract text from the Whisper result
26 text_to_summarize = Text["text"]
27
28 # Send the transcription to Groq for summarization
29 response = openai.ChatCompletion.create(
30 model="llama3-8b-8192",
31 messages=[
32 {
33 "role": "system",
34 "content": "You are a helpful assistant who summarizes long text into bullet points.",
35 },
36 {
37 "role": "user",
38 "content": f"Summarize the following:\n\n{text_to_summarize}",
39 },
40 ],
41 )
42
43 # Split the response into sentences
44 summary = re.split(r"(?<=[.!?]) +", response["choices"][0]["message"]["content"])
45
46 # Save summary to file
47 with open("summary.txt", "w+", encoding="utf-8") as file:
48 for sentence in summary:
49 cleaned = sentence.strip()
50 if cleaned:
51 file.write("- " + cleaned + "\n")
52
53
54if __name__ == "__main__":

Callers 1

transcript_generatorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected