From 5cedbec10fc0e7da31f44fe02584d239248e6038 Mon Sep 17 00:00:00 2001 From: Ray Smets Date: Fri, 24 Nov 2023 10:00:32 -0800 Subject: [PATCH] [Image] file saved along side the corresponding audio file. --- narrator.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/narrator.py b/narrator.py index 776ae66..1bd83d8 100644 --- a/narrator.py +++ b/narrator.py @@ -51,7 +51,7 @@ def play_audio(text): stream(audio) return - # Save the audio to a file and play it + # Save the audio to a file unique_id = base64.urlsafe_b64encode(os.urandom(30)).decode("utf-8").rstrip("=") dir_path = os.path.join("narration", unique_id) os.makedirs(dir_path, exist_ok=True) @@ -60,6 +60,12 @@ def play_audio(text): with open(file_path, "wb") as f: f.write(audio) + # Copy the image analyzed to the same directory as the audio file + image_path = os.path.join(os.getcwd(), "./frames/frame.jpg") + new_image_path = os.path.join(dir_path, "image.jpg") + os.system(f"cp {image_path} {new_image_path}") + + # Play the audio play(audio)