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'):
|
||||
try:
|
||||
print("Starting audio download.")
|
||||
yt = YouTube(video_url)
|
||||
audio_stream = yt.streams.get_audio_only()
|
||||
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):
|
||||
try:
|
||||
client = OpenAI(api_key=OPENAI_API_KEY)
|
||||
print("Transcription started.")
|
||||
|
||||
client = OpenAI(api_key=OPENAI_API_KEY)
|
||||
audio_file = open(audio_filename, "rb")
|
||||
|
||||
transcript = client.audio.transcriptions.create(
|
||||
file=audio_file,
|
||||
model="whisper-1",
|
||||
language="en",
|
||||
prompt="",
|
||||
response_format="json",
|
||||
temperature=0.0
|
||||
)
|
||||
|
||||
print("Transcription finished")
|
||||
print("Transcription finished.")
|
||||
|
||||
return transcript
|
||||
except Exception as e:
|
||||
@@ -37,6 +35,7 @@ def transcription(OPENAI_API_KEY, audio_filename):
|
||||
|
||||
def summarize(OPENAI_API_KEY, transcript):
|
||||
try:
|
||||
print("Summarizing starting")
|
||||
client = OpenAI(api_key=OPENAI_API_KEY)
|
||||
stream = client.chat.completions.create(
|
||||
model="gpt-4",
|
||||
@@ -50,12 +49,15 @@ def summarize(OPENAI_API_KEY, transcript):
|
||||
for chunk in stream:
|
||||
if chunk.choices[0].delta.content is not None:
|
||||
print(chunk.choices[0].delta.content, end="", flush=True)
|
||||
|
||||
print("Summarizing finished")
|
||||
except Exception as e:
|
||||
print(f"Failed to summarize transcript: {e}")
|
||||
return None
|
||||
|
||||
def cleanup(audio_filename):
|
||||
try:
|
||||
print("Deleting audio file")
|
||||
os.remove(audio_filename)
|
||||
print(f"Deleted audio: {audio_filename}")
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user