Spaces:
Build error
Build error
durganihantri
commited on
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
from flask import Flask, request, jsonify
|
| 2 |
-
import cv2
|
| 3 |
-
import speech_recognition as sr
|
| 4 |
-
from deepface import DeepFace
|
| 5 |
-
|
| 6 |
-
app = Flask(__name__)
|
| 7 |
-
|
| 8 |
-
@app.route('/analyze_face', methods=['POST'])
|
| 9 |
-
def analyze_face():
|
| 10 |
-
file = request.files['video']
|
| 11 |
-
video_path = "uploaded_video.mp4"
|
| 12 |
-
file.save(video_path)
|
| 13 |
-
|
| 14 |
-
cap = cv2.VideoCapture(video_path)
|
| 15 |
-
emotions = []
|
| 16 |
-
|
| 17 |
-
while True:
|
| 18 |
-
ret, frame = cap.read()
|
| 19 |
-
if not ret:
|
| 20 |
-
break
|
| 21 |
-
analysis = DeepFace.analyze(frame, actions=['emotion'])
|
| 22 |
-
emotions.append(analysis[0]['dominant_emotion'])
|
| 23 |
-
|
| 24 |
-
cap.release()
|
| 25 |
-
return jsonify({"emotions": emotions})
|
| 26 |
-
|
| 27 |
-
@app.route('/analyze_speech', methods=['POST'])
|
| 28 |
-
def analyze_speech():
|
| 29 |
-
file = request.files['audio']
|
| 30 |
-
audio_path = "uploaded_audio.wav"
|
| 31 |
-
file.save(audio_path)
|
| 32 |
-
|
| 33 |
-
recognizer = sr.Recognizer()
|
| 34 |
-
with sr.AudioFile(audio_path) as source:
|
| 35 |
-
audio = recognizer.record(source)
|
| 36 |
-
text = recognizer.recognize_google(audio)
|
| 37 |
-
|
| 38 |
-
return jsonify({"transcribed_text": text})
|
| 39 |
-
|
| 40 |
-
if __name__ == '__main__':
|
| 41 |
-
app.run(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|