Spaces:
Sleeping
Sleeping
adeelshuaib
commited on
Commit
•
734f006
1
Parent(s):
bcd4212
Update app.py
Browse files
app.py
CHANGED
@@ -37,10 +37,17 @@ def generate_audio_question(question):
|
|
37 |
waveforms = voc_model.decode_batch(mel_output)
|
38 |
return waveforms[0].numpy()
|
39 |
|
40 |
-
# Function to process audio response
|
41 |
def process_audio_response(audio):
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# Gradio interface functions
|
46 |
def text_part(candidate_name, responses):
|
@@ -56,8 +63,14 @@ def text_part(candidate_name, responses):
|
|
56 |
return df, plt
|
57 |
|
58 |
def audio_part(candidate_name, audio_responses):
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
df = pd.DataFrame(traits.items(), columns=["Trait", "Score"])
|
62 |
plt.figure(figsize=(8, 6))
|
63 |
plt.bar(df["Trait"], df["Score"], color="lightcoral")
|
@@ -68,6 +81,7 @@ def audio_part(candidate_name, audio_responses):
|
|
68 |
plt.tight_layout()
|
69 |
return df, plt
|
70 |
|
|
|
71 |
# Gradio UI function
|
72 |
def chat_interface(candidate_name, *responses):
|
73 |
# Separate text responses and audio responses
|
|
|
37 |
waveforms = voc_model.decode_batch(mel_output)
|
38 |
return waveforms[0].numpy()
|
39 |
|
|
|
40 |
def process_audio_response(audio):
|
41 |
+
# Check if the audio input is None
|
42 |
+
if audio is None:
|
43 |
+
return "No audio provided"
|
44 |
+
|
45 |
+
# Process the audio if it's a valid input
|
46 |
+
try:
|
47 |
+
text_response = asr_model.transcribe_file(audio)
|
48 |
+
return text_response
|
49 |
+
except Exception as e:
|
50 |
+
return f"Error processing audio: {str(e)}"
|
51 |
|
52 |
# Gradio interface functions
|
53 |
def text_part(candidate_name, responses):
|
|
|
63 |
return df, plt
|
64 |
|
65 |
def audio_part(candidate_name, audio_responses):
|
66 |
+
# Check if any audio response is invalid (None)
|
67 |
+
valid_audio_responses = [process_audio_response(audio) for audio in audio_responses if audio is not None]
|
68 |
+
|
69 |
+
# If all responses are invalid, return an error message
|
70 |
+
if not valid_audio_responses:
|
71 |
+
return "No valid audio responses provided", None
|
72 |
+
|
73 |
+
traits = analyze_text_responses(valid_audio_responses)
|
74 |
df = pd.DataFrame(traits.items(), columns=["Trait", "Score"])
|
75 |
plt.figure(figsize=(8, 6))
|
76 |
plt.bar(df["Trait"], df["Score"], color="lightcoral")
|
|
|
81 |
plt.tight_layout()
|
82 |
return df, plt
|
83 |
|
84 |
+
|
85 |
# Gradio UI function
|
86 |
def chat_interface(candidate_name, *responses):
|
87 |
# Separate text responses and audio responses
|