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")
|
print("Transcription finished")
|
||||||
|
|
||||||
os.remove(audio_filename)
|
|
||||||
|
|
||||||
return transcript
|
return transcript
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to transcript audio: {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}")
|
print(f"Failed to summarize transcript: {e}")
|
||||||
return None
|
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():
|
def main():
|
||||||
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')
|
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')
|
||||||
video_url = str(input("video url:"))
|
video_url = str(input("video url:"))
|
||||||
audio_filename = download_audio(video_url)
|
audio_filename = download_audio(video_url)
|
||||||
transcript = transcription(OPENAI_API_KEY, audio_filename)
|
transcript = transcription(OPENAI_API_KEY, audio_filename)
|
||||||
summarize(OPENAI_API_KEY, transcript)
|
summarize(OPENAI_API_KEY, transcript)
|
||||||
|
cleanup(audio_filename)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user