Skip to content
Snippets Groups Projects
Commit 166ff2a7 authored by Amel Abdic's avatar Amel Abdic :8ball:
Browse files

Implemented Subtitles

parent 42135c4a
No related branches found
No related tags found
No related merge requests found
import os
import textwrap
from turtle import position
import warnings
......@@ -109,6 +110,7 @@ class Main:
self.flag = False
self.selection = 3
self.it = 0
self.text = None
......@@ -163,6 +165,7 @@ class Main:
generated_text = result['openai']['generated_text']
print(generated_text)
self.speak_in_thread(generated_text)
self.text = generated_text
except Exception as e:
print(f"Fehler beim Senden/Empfangen der Daten zu/von ChatGPT: {e}")
......@@ -216,7 +219,10 @@ class Main:
cv2.putText(frame, f'Approx. Age: {analyze.get("age", "N/A")}', (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 0, 255), 2)
cv2.putText(frame, f'Approx. Gender: {analyze.get("dominant_gender", "N/A")}', (x, y - 40), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 255), 2)
cv2.putText(frame, f'Current emotion: {analyze.get("dominant_emotion", "N/A")}', (x, y - 70), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (255, 255, 0), 2)
if self.text != None:
new_text = textwrap.fill(self.text, width=35)
for i, line in enumerate(new_text.split('\n')):
cv2.putText(frame, line, (50, 900 + i * 30), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (255, 255, 255), 2)
emotion = analyze.get("dominant_emotion", "N/A")
if emotion in emoji_images:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment