put in a function the cleanup
This commit is contained in:
11
main.py
11
main.py
@@ -30,8 +30,6 @@ def transcription(OPENAI_API_KEY, audio_filename):
|
||||
|
||||
print("Transcription finished")
|
||||
|
||||
os.remove(audio_filename)
|
||||
|
||||
return transcript
|
||||
except Exception as e:
|
||||
print(f"Failed to transcript audio: {e}")
|
||||
@@ -56,12 +54,21 @@ def summarize(OPENAI_API_KEY, transcript):
|
||||
print(f"Failed to summarize transcript: {e}")
|
||||
return None
|
||||
|
||||
def cleanup(audio_filename):
|
||||
try:
|
||||
os.remove(audio_filename)
|
||||
print(f"Deleted audio: {audio_filename}")
|
||||
except Exception as e:
|
||||
print(f"Failed to delete audio: {audio_filename}: {e}")
|
||||
return None
|
||||
|
||||
def main():
|
||||
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')
|
||||
video_url = str(input("video url:"))
|
||||
audio_filename = download_audio(video_url)
|
||||
transcript = transcription(OPENAI_API_KEY, audio_filename)
|
||||
summarize(OPENAI_API_KEY, transcript)
|
||||
cleanup(audio_filename)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user