Spaces:
Build error
Build error
Commit
·
1bfd79c
1
Parent(s):
da18c29
12 Oct Gitex 2024
Browse files
tabs/speech_stress_analysis.py
CHANGED
|
@@ -37,7 +37,6 @@ def analyze_voice_stress(audio_file):
|
|
| 37 |
print(f"Variance Pitches: {var_pitches}")
|
| 38 |
|
| 39 |
# Normalize each variance using Z-Score Standardization
|
| 40 |
-
# These parameters should be calibrated based on a representative dataset
|
| 41 |
mfccs_mean = 1000
|
| 42 |
mfccs_std = 500
|
| 43 |
energy_mean = 0.005
|
|
@@ -113,14 +112,15 @@ def create_voice_stress_tab():
|
|
| 113 |
with gr.Row():
|
| 114 |
with gr.Column(scale=2):
|
| 115 |
input_audio = gr.Audio(label="Input Audio", type="filepath")
|
| 116 |
-
|
| 117 |
-
clear_btn = gr.Button("Clear", scale=1)
|
| 118 |
-
submit_btn = gr.Button("Analyze", scale=1, elem_classes="submit")
|
| 119 |
with gr.Column(scale=1):
|
| 120 |
output_stress = gr.Label(label="Stress Level")
|
| 121 |
output_plot = gr.Image(label="Stress Analysis Plot")
|
| 122 |
|
| 123 |
-
|
|
|
|
|
|
|
| 124 |
clear_btn.click(lambda: (None, None), outputs=[input_audio, output_stress, output_plot])
|
| 125 |
|
| 126 |
gr.Examples(["./assets/audio/fitness.wav"], inputs=[input_audio])
|
|
|
|
|
|
| 37 |
print(f"Variance Pitches: {var_pitches}")
|
| 38 |
|
| 39 |
# Normalize each variance using Z-Score Standardization
|
|
|
|
| 40 |
mfccs_mean = 1000
|
| 41 |
mfccs_std = 500
|
| 42 |
energy_mean = 0.005
|
|
|
|
| 112 |
with gr.Row():
|
| 113 |
with gr.Column(scale=2):
|
| 114 |
input_audio = gr.Audio(label="Input Audio", type="filepath")
|
| 115 |
+
clear_btn = gr.Button("Clear", scale=1)
|
|
|
|
|
|
|
| 116 |
with gr.Column(scale=1):
|
| 117 |
output_stress = gr.Label(label="Stress Level")
|
| 118 |
output_plot = gr.Image(label="Stress Analysis Plot")
|
| 119 |
|
| 120 |
+
# Automatically trigger analysis when an audio file is uploaded
|
| 121 |
+
input_audio.change(analyze_voice_stress, inputs=[input_audio], outputs=[output_stress, output_plot])
|
| 122 |
+
|
| 123 |
clear_btn.click(lambda: (None, None), outputs=[input_audio, output_stress, output_plot])
|
| 124 |
|
| 125 |
gr.Examples(["./assets/audio/fitness.wav"], inputs=[input_audio])
|
| 126 |
+
|