added print statement to describe whats happening
This commit is contained in:
14
main.py
14
main.py
@@ -4,6 +4,7 @@ from pytube import YouTube
|
|||||||
|
|
||||||
def download_audio(video_url, output_filename='audio.mp4'):
|
def download_audio(video_url, output_filename='audio.mp4'):
|
||||||
try:
|
try:
|
||||||
|
print("Starting audio download.")
|
||||||
yt = YouTube(video_url)
|
yt = YouTube(video_url)
|
||||||
audio_stream = yt.streams.get_audio_only()
|
audio_stream = yt.streams.get_audio_only()
|
||||||
audio_filename = audio_stream.download(filename=output_filename)
|
audio_filename = audio_stream.download(filename=output_filename)
|
||||||
@@ -15,20 +16,17 @@ def download_audio(video_url, output_filename='audio.mp4'):
|
|||||||
|
|
||||||
def transcription(OPENAI_API_KEY, audio_filename):
|
def transcription(OPENAI_API_KEY, audio_filename):
|
||||||
try:
|
try:
|
||||||
client = OpenAI(api_key=OPENAI_API_KEY)
|
print("Transcription started.")
|
||||||
|
|
||||||
|
client = OpenAI(api_key=OPENAI_API_KEY)
|
||||||
audio_file = open(audio_filename, "rb")
|
audio_file = open(audio_filename, "rb")
|
||||||
|
|
||||||
transcript = client.audio.transcriptions.create(
|
transcript = client.audio.transcriptions.create(
|
||||||
file=audio_file,
|
file=audio_file,
|
||||||
model="whisper-1",
|
model="whisper-1",
|
||||||
language="en",
|
|
||||||
prompt="",
|
|
||||||
response_format="json",
|
|
||||||
temperature=0.0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Transcription finished")
|
print("Transcription finished.")
|
||||||
|
|
||||||
return transcript
|
return transcript
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -37,6 +35,7 @@ def transcription(OPENAI_API_KEY, audio_filename):
|
|||||||
|
|
||||||
def summarize(OPENAI_API_KEY, transcript):
|
def summarize(OPENAI_API_KEY, transcript):
|
||||||
try:
|
try:
|
||||||
|
print("Summarizing starting")
|
||||||
client = OpenAI(api_key=OPENAI_API_KEY)
|
client = OpenAI(api_key=OPENAI_API_KEY)
|
||||||
stream = client.chat.completions.create(
|
stream = client.chat.completions.create(
|
||||||
model="gpt-4",
|
model="gpt-4",
|
||||||
@@ -50,12 +49,15 @@ def summarize(OPENAI_API_KEY, transcript):
|
|||||||
for chunk in stream:
|
for chunk in stream:
|
||||||
if chunk.choices[0].delta.content is not None:
|
if chunk.choices[0].delta.content is not None:
|
||||||
print(chunk.choices[0].delta.content, end="", flush=True)
|
print(chunk.choices[0].delta.content, end="", flush=True)
|
||||||
|
|
||||||
|
print("Summarizing finished")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to summarize transcript: {e}")
|
print(f"Failed to summarize transcript: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def cleanup(audio_filename):
|
def cleanup(audio_filename):
|
||||||
try:
|
try:
|
||||||
|
print("Deleting audio file")
|
||||||
os.remove(audio_filename)
|
os.remove(audio_filename)
|
||||||
print(f"Deleted audio: {audio_filename}")
|
print(f"Deleted audio: {audio_filename}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user