Spaces:
Sleeping
Sleeping
ananyachavan
commited on
Commit
•
25d12aa
1
Parent(s):
95de7b4
Update app.py
Browse files
app.py
CHANGED
@@ -26,11 +26,18 @@ def transcribe_and_recognize_emotions(audio_file):
|
|
26 |
dominant_emotion = max(emotions[0], key=lambda x: x['score'])['label']
|
27 |
|
28 |
return transcription, dominant_emotion
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
# Define the Gradio interface function
|
31 |
def gradio_transcription_emotion_interface(audio):
|
32 |
transcription, emotion = transcribe_and_recognize_emotions(audio)
|
33 |
-
|
|
|
34 |
|
35 |
# Set up Gradio Interface
|
36 |
iface = gr.Interface(
|
@@ -38,11 +45,12 @@ iface = gr.Interface(
|
|
38 |
inputs=gr.Audio(type="filepath"),
|
39 |
outputs=[
|
40 |
gr.Textbox(label="Transcription"),
|
41 |
-
gr.Label(label="Dominant Emotion")
|
|
|
42 |
],
|
43 |
title="Audio Transcription and Emotion Recognition",
|
44 |
-
description="Upload or record an audio file to get the transcription
|
45 |
)
|
46 |
-
|
47 |
# Deploy the interface
|
48 |
iface.launch(debug=True)
|
|
|
|
26 |
dominant_emotion = max(emotions[0], key=lambda x: x['score'])['label']
|
27 |
|
28 |
return transcription, dominant_emotion
|
29 |
+
|
30 |
+
# Simulated function to analyze speech patterns and prosody for mental health
|
31 |
+
def analyze_speech_for_mental_health(audio_file):
|
32 |
+
# Here you would use a model or algorithm to analyze speech patterns, prosody, etc.
|
33 |
+
# For demonstration purposes, we'll simulate this with a placeholder response.
|
34 |
+
return "Simulated mental health analysis: No significant signs of depression or anxiety detected."
|
35 |
|
36 |
# Define the Gradio interface function
|
37 |
def gradio_transcription_emotion_interface(audio):
|
38 |
transcription, emotion = transcribe_and_recognize_emotions(audio)
|
39 |
+
mental_health_assessment = analyze_speech_for_mental_health(audio)
|
40 |
+
return transcription, emotion, mental_health_assessment
|
41 |
|
42 |
# Set up Gradio Interface
|
43 |
iface = gr.Interface(
|
|
|
45 |
inputs=gr.Audio(type="filepath"),
|
46 |
outputs=[
|
47 |
gr.Textbox(label="Transcription"),
|
48 |
+
gr.Label(label="Dominant Emotion"),
|
49 |
+
gr.Textbox(label="Mental Health Assessment")
|
50 |
],
|
51 |
title="Audio Transcription and Emotion Recognition",
|
52 |
+
description="Upload or record an audio file to get the transcription, recognize its dominant emotion, and receive a mental health assessment."
|
53 |
)
|
|
|
54 |
# Deploy the interface
|
55 |
iface.launch(debug=True)
|
56 |
+
|