Spaces:
Sleeping
Sleeping
Commit
·
6e1a3ad
1
Parent(s):
3e1faf8
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import io
|
|
7 |
import pyttsx3
|
8 |
import time
|
9 |
import os
|
|
|
10 |
|
11 |
|
12 |
aws_key_id = os.environ['aws_access_key_id']
|
@@ -38,6 +39,11 @@ def speak_text(text):
|
|
38 |
engine.setProperty('rate', 185)
|
39 |
engine.say(text)
|
40 |
|
|
|
|
|
|
|
|
|
|
|
41 |
def recognize_emotions(image):
|
42 |
"""
|
43 |
This function takes an image as input, and returns the emotion with the highest confidence level in the face using AWS Rekognition
|
@@ -74,7 +80,8 @@ def recognize_emotions(image):
|
|
74 |
max_emotion = emotion['Type']
|
75 |
|
76 |
|
77 |
-
speak_text(f'This person is {max_emotion}')
|
|
|
78 |
|
79 |
# Return the emotion with the highest confidence level as a string
|
80 |
return str(max_emotion)
|
|
|
7 |
import pyttsx3
|
8 |
import time
|
9 |
import os
|
10 |
+
import subprocess
|
11 |
|
12 |
|
13 |
aws_key_id = os.environ['aws_access_key_id']
|
|
|
39 |
engine.setProperty('rate', 185)
|
40 |
engine.say(text)
|
41 |
|
42 |
+
|
43 |
+
def espeak(text: str, pitch: int=50) -> int:
|
44 |
+
""" Use espeak to convert text to speech. """
|
45 |
+
return subprocess.run(['espeak', f'-p {pitch}', text]).returncode
|
46 |
+
|
47 |
def recognize_emotions(image):
|
48 |
"""
|
49 |
This function takes an image as input, and returns the emotion with the highest confidence level in the face using AWS Rekognition
|
|
|
80 |
max_emotion = emotion['Type']
|
81 |
|
82 |
|
83 |
+
#speak_text(f'This person is {max_emotion}')
|
84 |
+
espeak(f'This person is {max_emotion}')
|
85 |
|
86 |
# Return the emotion with the highest confidence level as a string
|
87 |
return str(max_emotion)
|