Skip to content

update gcd #2639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
46 changes: 46 additions & 0 deletions Audio Summarizer
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import whisper
import re
import openai
import os

def transcript_generator():
# Load Whisper model
model = whisper.load_model("base")

# Transcribe audio file
result = model.transcribe("audio.mp4")

# Send the transcript to the summarizer
provide_summarizer(result)


def provide_summarizer(Text):
# Set up Groq OpenAI-compatible API credentials
openai.api_key = os.getenv("OPENAI_API_KEY", "your-api-key-here") # Replace or set in environment
openai.api_base = "https://api.groq.com/openai/v1"

# Extract text from the Whisper result
text_to_summarize = Text["text"]

# Send the transcription to Groq for summarization
response = openai.ChatCompletion.create(
model="llama3-8b-8192",
messages=[
{"role": "system", "content": "You are a helpful assistant who summarizes long text into bullet points."},
{"role": "user", "content": f"Summarize the following:\n\n{text_to_summarize}"}
]
)

# Split the response into sentences
summary = re.split(r'(?<=[.!?]) +', response["choices"][0]["message"]["content"])

# Save summary to file
with open("summary.txt", "w+", encoding="utf-8") as file:
for sentence in summary:
cleaned = sentence.strip()
if cleaned:
file.write("- " + cleaned + "\n")


if __name__ == "__main__":
transcript_generator()
46 changes: 46 additions & 0 deletions Audio_Summarizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import whisper
import re
import openai
import os

def transcript_generator():
# Load Whisper model
model = whisper.load_model("base")

# Transcribe audio file
result = model.transcribe("audio.mp4")

# Send the transcript to the summarizer
provide_summarizer(result)


def provide_summarizer(Text):
# Set up Groq OpenAI-compatible API credentials
openai.api_key = os.getenv("OPENAI_API_KEY", "your-api-key-here") # Replace or set in environment
openai.api_base = "https://api.groq.com/openai/v1"

# Extract text from the Whisper result
text_to_summarize = Text["text"]

# Send the transcription to Groq for summarization
response = openai.ChatCompletion.create(
model="llama3-8b-8192",
messages=[
{"role": "system", "content": "You are a helpful assistant who summarizes long text into bullet points."},
{"role": "user", "content": f"Summarize the following:\n\n{text_to_summarize}"}
]
)

# Split the response into sentences
summary = re.split(r'(?<=[.!?]) +', response["choices"][0]["message"]["content"])

# Save summary to file
with open("summary.txt", "w+", encoding="utf-8") as file:
for sentence in summary:
cleaned = sentence.strip()
if cleaned:
file.write("- " + cleaned + "\n")


if __name__ == "__main__":
transcript_generator()
6 changes: 3 additions & 3 deletions String_Palindrome.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Program to check if a string is palindrome or not

my_str = 'aIbohPhoBiA'
my_str = input().strip()

# make it suitable for caseless comparison
my_str = my_str.casefold()

# reverse the string
rev_str = reversed(my_str)
rev_str = my_str[::-1]

# check if the string is equal to its reverse
if list(my_str) == list(rev_str):
if my_str == rev_str:
print("The string is a palindrome.")
else:
print("The string is not a palindrome.")
10 changes: 5 additions & 5 deletions gcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
a = int(input("Enter number 1 (a): "))
b = int(input("Enter number 2 (b): "))

i = 1
while i <= a and i <= b:
if a % i == 0 and b % i == 0:
gcd = i
i = i + 1
def calc_GCD(x,y):
if y==0:
return x
return calc_GCD(y,x%y)
gcd=calc_GCD(a,b)

print("\nGCD of {0} and {1} = {2}".format(a, b, gcd))