diff --git a/capture.py b/capture.py index 2350ccc..52bf8aa 100644 --- a/capture.py +++ b/capture.py @@ -37,13 +37,13 @@ while True: frame = cv2.cvtColor(np.array(resized_img), cv2.COLOR_RGB2BGR) # Save the frame as an image file - print("📸 Say cheese! Saving frame.") + print("📸 Sorridi! Ti sto riprendendo.") path = f"{folder}/frame.jpg" # Showing captured frame cv2.imshow("image", frame) # Keeps window open till the next cycle runs - cv2.waitKey(4900) + cv2.waitKey(1900) # Writing frame on disk cv2.imwrite(path, frame) @@ -51,7 +51,7 @@ while True: print("Failed to capture image") # Wait for 2 seconds - time.sleep(2) + # time.sleep(2) # Release the camera and close all windows cap.release() diff --git a/narrator.py b/narrator.py index 9cf6d78..147bec7 100644 --- a/narrator.py +++ b/narrator.py @@ -25,7 +25,7 @@ def encode_image(image_path): def play_audio(text): - audio = generate(text, voice=os.environ.get("ELEVENLABS_VOICE_ID")) + audio = generate(text, voice=os.environ.get("ELEVENLABS_VOICE_ID"), model="eleven_multilingual_v2") unique_id = base64.urlsafe_b64encode(os.urandom(30)).decode("utf-8").rstrip("=") dir_path = os.path.join("narration", unique_id) @@ -43,7 +43,7 @@ def generate_new_line(base64_image): { "role": "user", "content": [ - {"type": "text", "text": "Describe this image"}, + {"type": "text", "text": "Continua il racconto del documentario naturalistico sull'essere umano nell'immagine."}, { "type": "image_url", "image_url": f"data:image/jpeg;base64,{base64_image}", @@ -60,8 +60,9 @@ def analyze_image(base64_image, script): { "role": "system", "content": """ - Sei Piero Angela. Narra ciò che fa l'essere umano nella foto come se fosse un documentario naturalistico. - Rendilo ironico e divertente. Non ripeterti. Rendilo breve. Se fa qualcosa di anche lontanamente interessante, sottolinealo con enfasi! + Sei Piero Angela. Descrivi in italiano le azioni dell'essere umano nell'immagine come se fosse il protagonista di un documentario naturalistico. + Sii ironico e divertente. Non ripeterti. Sii breve. Usa un linguaggio forbito e ricco di termini del gergo scientifico. Sottolinea con enfasi ogni minima cosa che fa! + Limitati a un massimo di 30 parole. """, }, ] @@ -84,7 +85,7 @@ def main(): base64_image = encode_image(image_path) # analyze posture - print("👀 Piero ti sta guardando...") + print("👀 Piero ti sta osservando...") analysis = analyze_image(base64_image, script=script) print("🎙️ Piero dice:") @@ -94,8 +95,8 @@ def main(): script = script + [{"role": "assistant", "content": analysis}] - # wait for 5 seconds - time.sleep(5) + # wait for 1 seconds + time.sleep(1) if __name__ == "__main__":