Spaces:
Sleeping
Sleeping
Ranam Hamoud
commited on
Commit
·
4c2ceb8
1
Parent(s):
95ad43e
Add example audio files and update app with examples
Browse files- app.py +54 -2
- examples/read1.ogg +3 -0
- examples/read4.wav +3 -0
- examples/spontaneous1.ogg +3 -0
- pipeline.py +1 -1
app.py
CHANGED
|
@@ -14,13 +14,13 @@ def analyze_audio_file(audio_file):
|
|
| 14 |
if not pipeline_ready:
|
| 15 |
return (
|
| 16 |
"Error: Pipeline not initialized. Please check the installation.",
|
| 17 |
-
"", "", "", ""
|
| 18 |
)
|
| 19 |
|
| 20 |
if audio_file is None:
|
| 21 |
return (
|
| 22 |
"Please upload an audio file.",
|
| 23 |
-
"", "", "", ""
|
| 24 |
)
|
| 25 |
|
| 26 |
try:
|
|
@@ -343,6 +343,25 @@ def create_interface():
|
|
| 343 |
size="lg"
|
| 344 |
)
|
| 345 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
gr.HTML("""
|
| 347 |
<div style='background: white; border: 1px solid #e5e7eb; padding: 20px; border-radius: 16px; margin-top: 20px;'>
|
| 348 |
<h4 style='margin: 0 0 12px 0; font-size: 14px; font-weight: 600; color: #111827;'>Requirements</h4>
|
|
@@ -385,7 +404,40 @@ def create_interface():
|
|
| 385 |
|
| 386 |
|
| 387 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 388 |
analyze_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
fn=analyze_audio_file,
|
| 390 |
inputs=[audio_input],
|
| 391 |
outputs=[
|
|
|
|
| 14 |
if not pipeline_ready:
|
| 15 |
return (
|
| 16 |
"Error: Pipeline not initialized. Please check the installation.",
|
| 17 |
+
"", "", "", ""
|
| 18 |
)
|
| 19 |
|
| 20 |
if audio_file is None:
|
| 21 |
return (
|
| 22 |
"Please upload an audio file.",
|
| 23 |
+
"", "", "", ""
|
| 24 |
)
|
| 25 |
|
| 26 |
try:
|
|
|
|
| 343 |
size="lg"
|
| 344 |
)
|
| 345 |
|
| 346 |
+
# Add example audio files
|
| 347 |
+
gr.HTML("""
|
| 348 |
+
<div style='margin-top: 20px; margin-bottom: 10px;'>
|
| 349 |
+
<h4 style='margin: 0 0 8px 0; font-size: 14px; font-weight: 600; color: #111827;'>Try these examples:</h4>
|
| 350 |
+
</div>
|
| 351 |
+
""")
|
| 352 |
+
|
| 353 |
+
examples_dir = os.path.join(os.path.dirname(__file__), "examples")
|
| 354 |
+
gr.Examples(
|
| 355 |
+
examples=[
|
| 356 |
+
[os.path.join(examples_dir, "read1.ogg")],
|
| 357 |
+
[os.path.join(examples_dir, "spontaneous1.ogg")]
|
| 358 |
+
],
|
| 359 |
+
inputs=[audio_input],
|
| 360 |
+
label="",
|
| 361 |
+
examples_per_page=2,
|
| 362 |
+
cache_examples=False
|
| 363 |
+
)
|
| 364 |
+
|
| 365 |
gr.HTML("""
|
| 366 |
<div style='background: white; border: 1px solid #e5e7eb; padding: 20px; border-radius: 16px; margin-top: 20px;'>
|
| 367 |
<h4 style='margin: 0 0 12px 0; font-size: 14px; font-weight: 600; color: #111827;'>Requirements</h4>
|
|
|
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
+
def show_loading():
|
| 408 |
+
loading_html = """
|
| 409 |
+
<div style='background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border: 2px solid #667eea; padding: 30px; border-radius: 16px; margin: 10px 0; text-align: center;'>
|
| 410 |
+
<h2 style='color: white; margin: 0 0 15px 0; font-size: 24px; font-weight: 700;'>
|
| 411 |
+
Analyzing...
|
| 412 |
+
</h2>
|
| 413 |
+
<div style='margin-top: 20px;'>
|
| 414 |
+
<div style='display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: white; margin: 0 4px; animation: pulse 1.5s ease-in-out infinite;'></div>
|
| 415 |
+
<div style='display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: white; margin: 0 4px; animation: pulse 1.5s ease-in-out 0.2s infinite;'></div>
|
| 416 |
+
<div style='display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: white; margin: 0 4px; animation: pulse 1.5s ease-in-out 0.4s infinite;'></div>
|
| 417 |
+
</div>
|
| 418 |
+
</div>
|
| 419 |
+
<style>
|
| 420 |
+
@keyframes pulse {
|
| 421 |
+
0%, 100% { opacity: 0.3; transform: scale(0.8); }
|
| 422 |
+
50% { opacity: 1; transform: scale(1.2); }
|
| 423 |
+
}
|
| 424 |
+
</style>
|
| 425 |
+
"""
|
| 426 |
+
loading_msg = " **Processing...**"
|
| 427 |
+
return loading_html, loading_msg, loading_msg, loading_msg, loading_msg
|
| 428 |
+
|
| 429 |
analyze_btn.click(
|
| 430 |
+
fn=show_loading,
|
| 431 |
+
inputs=None,
|
| 432 |
+
outputs=[
|
| 433 |
+
overall_output,
|
| 434 |
+
acoustic_output,
|
| 435 |
+
transcription_output,
|
| 436 |
+
speech_output,
|
| 437 |
+
ai_output,
|
| 438 |
+
],
|
| 439 |
+
queue=False
|
| 440 |
+
).then(
|
| 441 |
fn=analyze_audio_file,
|
| 442 |
inputs=[audio_input],
|
| 443 |
outputs=[
|
examples/read1.ogg
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a13e626fdda037d19f32574aa244b3c5d5d8cee9a29777bdc9aa2923ff1035d2
|
| 3 |
+
size 67654
|
examples/read4.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c9dbcda832552f5051a60de21bc10dd1166cfb7039077e4108d6a8e239148ec3
|
| 3 |
+
size 898430
|
examples/spontaneous1.ogg
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6bece27541be3a7e5b09132eec245c141d26b5114a44ba3124b8678914b67345
|
| 3 |
+
size 102198
|
pipeline.py
CHANGED
|
@@ -48,7 +48,7 @@ class AuthenticityDetectionPipeline:
|
|
| 48 |
print("-" * 40)
|
| 49 |
audio_results = self.audio_classifier.classify(audio_path)
|
| 50 |
print(f"✓ CNN classification complete")
|
| 51 |
-
print(f" Classification: {audio_results['classification'].upper()}")
|
| 52 |
print(f" Confidence: {audio_results['confidence']*100:.1f}%")
|
| 53 |
|
| 54 |
# Stage 2: Speech Analysis (Whisper for linguistic analysis)
|
|
|
|
| 48 |
print("-" * 40)
|
| 49 |
audio_results = self.audio_classifier.classify(audio_path)
|
| 50 |
print(f"✓ CNN classification complete")
|
| 51 |
+
print(f" ## Classification: {audio_results['classification'].upper()}")
|
| 52 |
print(f" Confidence: {audio_results['confidence']*100:.1f}%")
|
| 53 |
|
| 54 |
# Stage 2: Speech Analysis (Whisper for linguistic analysis)
|