Spaces:
Sleeping
Sleeping
Russell Jeffrey
commited on
Commit
·
9532ac2
1
Parent(s):
c057b57
Files
Browse files- README.md +1 -1
- app/data/chroma_db/chroma.sqlite3 +3 -0
- app/data/chroma_db/d5c23adb-c674-4ef7-9e89-786622657d8b/data_level0.bin +3 -0
- app/data/chroma_db/d5c23adb-c674-4ef7-9e89-786622657d8b/header.bin +3 -0
- app/data/chroma_db/d5c23adb-c674-4ef7-9e89-786622657d8b/length.bin +3 -0
- app/data/chroma_db/d5c23adb-c674-4ef7-9e89-786622657d8b/link_lists.bin +0 -0
- app/models/emotion_detector/__init__.py +0 -0
- app/models/emotion_detector/detector.py +47 -0
- data/chroma_db/7452a30c-7444-4e00-b60d-9ead95a78ff7/data_level0.bin +3 -0
- data/chroma_db/7452a30c-7444-4e00-b60d-9ead95a78ff7/header.bin +3 -0
- data/chroma_db/7452a30c-7444-4e00-b60d-9ead95a78ff7/index_metadata.pickle +3 -0
- data/chroma_db/7452a30c-7444-4e00-b60d-9ead95a78ff7/length.bin +3 -0
- data/chroma_db/7452a30c-7444-4e00-b60d-9ead95a78ff7/link_lists.bin +3 -0
- data/chroma_db/chroma.sqlite3 +3 -0
- data/kb/Health Vision 2050.pdf +3 -0
- data/kb/IICBT Therapist Manual WB.pdf +3 -0
- data/kb/Islamic Trauma Healing.pdf +3 -0
- data/kb/MHFA Manual - Digital (June 2023).pdf +3 -0
- data/kb/MHPSS Vocabulary in Arabic.pdf +3 -0
- data/kb/WHO guidelines on mental health at work.pdf +3 -0
- data/kb/WHO mental health action plan.pdf +3 -0
- data/kb/few_shot_prompts.json +30 -0
- data/kb/perception towards illness in Oman.pdf +3 -0
- data/langsmith-elile-bot-runs-2025-09-27.csv +0 -0
- documentation/RAG_resources.md +55 -0
- documentation/arch_diagram.png +3 -0
- documentation/architecture.md +55 -0
- documentation/future_roadmap.md +80 -0
- documentation/latency.md +39 -0
- documentation/safety_protocol.md +49 -0
- documentation/wer_report.md +11 -0
- tests/audio_samples/audio_sample_1.wav +3 -0
- tests/audio_samples/audio_sample_2.wav +3 -0
- tests/audio_samples/audio_sample_3.wav +3 -0
- tests/audio_samples/audio_sample_4.wav +3 -0
- tests/audio_samples/audio_sample_5.wav +3 -0
- tests/crisis_toolchain_test.py +41 -0
- tests/test_wer.py +123 -0
- tests/transcripts/transcript1.txt +7 -0
- tests/transcripts/transcript2.txt +9 -0
- tests/transcripts/transcript3.txt +7 -0
- tests/transcripts/transcript4.txt +11 -0
- tests/transcripts/transcript5.txt +9 -0
- tests/wer_results.txt +25 -0
README.md
CHANGED
|
@@ -94,4 +94,4 @@ python -m pytest -s -v tests/
|
|
| 94 |
This project is for **demo purposes**.
|
| 95 |
It is **not a substitute for professional mental health care**. If someone is in crisis, they should seek immediate professional support.
|
| 96 |
|
| 97 |
-
---
|
|
|
|
| 94 |
This project is for **demo purposes**.
|
| 95 |
It is **not a substitute for professional mental health care**. If someone is in crisis, they should seek immediate professional support.
|
| 96 |
|
| 97 |
+
---
|
app/data/chroma_db/chroma.sqlite3
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bed3d5e34b1fc368b1ac9d6211561f4eaf52e3e14092fcf33952cef1768131da
|
| 3 |
+
size 167936
|
app/data/chroma_db/d5c23adb-c674-4ef7-9e89-786622657d8b/data_level0.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:065a5aa61390e7ff9c4d37dbb028fd9a866fd618df83adeb7b41c957a09d4dc0
|
| 3 |
+
size 628400
|
app/data/chroma_db/d5c23adb-c674-4ef7-9e89-786622657d8b/header.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b081be2c2276a57e995075c7de2f3cb25e903798aac36d98042045533ab28f7d
|
| 3 |
+
size 100
|
app/data/chroma_db/d5c23adb-c674-4ef7-9e89-786622657d8b/length.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2c026411ef7291c94b7582da32827c1d48fd1672026c9de7b8b014703f5b6753
|
| 3 |
+
size 400
|
app/data/chroma_db/d5c23adb-c674-4ef7-9e89-786622657d8b/link_lists.bin
ADDED
|
File without changes
|
app/models/emotion_detector/__init__.py
ADDED
|
File without changes
|
app/models/emotion_detector/detector.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import logging
|
| 3 |
+
|
| 4 |
+
logging.basicConfig(
|
| 5 |
+
filename="crisis_log.txt",
|
| 6 |
+
level=logging.INFO,
|
| 7 |
+
format="%(asctime)s - %(message)s"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
# GoEmotions human-readable labels
|
| 11 |
+
GO_EMOTION_LABELS = [
|
| 12 |
+
"admiration", "amusement", "anger", "annoyance", "approval", "caring", "confusion",
|
| 13 |
+
"curiosity", "desire", "disappointment", "disapproval", "disgust", "embarrassment",
|
| 14 |
+
"excitement", "fear", "gratitude", "grief", "joy", "love", "nervousness",
|
| 15 |
+
"optimism", "pride", "realization", "relief", "remorse", "sadness", "surprise", "neutral"
|
| 16 |
+
]
|
| 17 |
+
|
| 18 |
+
def load_emotion_classifier():
|
| 19 |
+
"""Load the emotion detection model."""
|
| 20 |
+
try:
|
| 21 |
+
classifier = pipeline("text-classification", model="AnasAlokla/multilingual_go_emotions_V1.1", framework="pt")
|
| 22 |
+
return classifier
|
| 23 |
+
except Exception as e:
|
| 24 |
+
logging.error(f"Error loading emotion classifier: {str(e)}")
|
| 25 |
+
return None
|
| 26 |
+
|
| 27 |
+
def detect_emotions(text, classifier):
|
| 28 |
+
"""Detect emotions in text with human-readable labels."""
|
| 29 |
+
if not classifier:
|
| 30 |
+
logging.error("Emotion classifier not loaded")
|
| 31 |
+
return [{"label": "error", "score": 0.0}]
|
| 32 |
+
|
| 33 |
+
raw_results = classifier(text, top_k=3)
|
| 34 |
+
human_results = []
|
| 35 |
+
for item in raw_results:
|
| 36 |
+
raw_label = item['label']
|
| 37 |
+
# Only split if it's in LABEL_X format
|
| 38 |
+
if raw_label.startswith("LABEL_"):
|
| 39 |
+
try:
|
| 40 |
+
idx = int(raw_label.split('_')[1])
|
| 41 |
+
label = GO_EMOTION_LABELS[idx] if idx < len(GO_EMOTION_LABELS) else raw_label
|
| 42 |
+
except (IndexError, ValueError):
|
| 43 |
+
label = raw_label
|
| 44 |
+
else:
|
| 45 |
+
label = raw_label
|
| 46 |
+
human_results.append({"label": label, "score": item['score']})
|
| 47 |
+
return human_results
|
data/chroma_db/7452a30c-7444-4e00-b60d-9ead95a78ff7/data_level0.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:24b6125b97ee283638c7bb54e7295e191f1708cb27db37c12a3b3099629b990b
|
| 3 |
+
size 14905648
|
data/chroma_db/7452a30c-7444-4e00-b60d-9ead95a78ff7/header.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:28bcd691202c5581a9bad9d1c130684120dfe2c4c1b391775cc9e9a80939a435
|
| 3 |
+
size 100
|
data/chroma_db/7452a30c-7444-4e00-b60d-9ead95a78ff7/index_metadata.pickle
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:98d5dedd29b510d0c61e715b19ae9ac0f02d21f8446f6d05a285e3252e78fa24
|
| 3 |
+
size 218360
|
data/chroma_db/7452a30c-7444-4e00-b60d-9ead95a78ff7/length.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:700ba5b25c2ff908f0b3ddb5ab265dd9a869df6c8bd44bd8e6a79be503869ae5
|
| 3 |
+
size 9488
|
data/chroma_db/7452a30c-7444-4e00-b60d-9ead95a78ff7/link_lists.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d701db585bb7d1956fd952d441c353dfd22fbe0c12e21c3d3dccbe33ed4d17c6
|
| 3 |
+
size 21388
|
data/chroma_db/chroma.sqlite3
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:09f6e5a427f57ab1dfad6979415ce328a6d245e00f7502f125c200febb52eb70
|
| 3 |
+
size 38027264
|
data/kb/Health Vision 2050.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed3ab4e72bdfff0eb0c916fb1794a7ab6cce9eb09aa05fd8a933dc0a9e95f598
|
| 3 |
+
size 9870145
|
data/kb/IICBT Therapist Manual WB.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:29a01cd8d7e15ccd4efa2384b01443a43376f5f87f6a8b6bcc73d9c9c9df1c0b
|
| 3 |
+
size 1087461
|
data/kb/Islamic Trauma Healing.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:88c95b7975d349bbbf8b7d134a09d2652a832f37f6e173abd3e9369db0a549e0
|
| 3 |
+
size 3866553
|
data/kb/MHFA Manual - Digital (June 2023).pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5da0db93f6af87c61a2310f7112735ec98b30b7949588e504bcd6616594c69a2
|
| 3 |
+
size 5566780
|
data/kb/MHPSS Vocabulary in Arabic.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f6a77a9801ce99e184aeba94059a78dcb54db49b57878d8f0d06de85bbcde03f
|
| 3 |
+
size 704410
|
data/kb/WHO guidelines on mental health at work.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fabbc1aae233c14bdd9f37f19a00c7951cdbf2c9c0c455d7bbe85222afdc3f60
|
| 3 |
+
size 5434784
|
data/kb/WHO mental health action plan.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:635babf8f40026e039f49dd88f0fda331e4c97b1c3f30f356041016c5271b11f
|
| 3 |
+
size 3011507
|
data/kb/few_shot_prompts.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"examples": [
|
| 3 |
+
{
|
| 4 |
+
"user": "أنا حزين جدًا وما أقدر أنام.",
|
| 5 |
+
"context": "User is expressing sadness and insomnia, likely depression symptoms.",
|
| 6 |
+
"response": "أنا آسف إنك تشعر بهالطريقة. في عُمان، يمكنك الاتصال بمستشفى المسارة على 2487 3268 للحصول على مساعدة متخصصة. جرب تمارين التنفس العميق: استلقِ وخذ نفسًا عميقًا لـ4 ثوانٍ، احبسه لـ4، أخرجه لـ4."
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"user": "كيف أتعامل مع القلق في العمل؟",
|
| 10 |
+
"context": "User seeking anxiety management tips, incorporate CBT from KB.",
|
| 11 |
+
"response": "القلق شائع، خاصة في بيئة العمل. جرب تقنية CBT: حدد الفكرة السلبية، ثم تحداها بأدلة إيجابية. في الخليج، موارد مثل تمارين الاسترخاء متوفرة في gult_region_resources. إذا استمر، استشر طبيبًا نفسيًا في مسقط."
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"user": "أشعر بالوحدة في مسقط.",
|
| 15 |
+
"context": "Loneliness, suggest cultural resources.",
|
| 16 |
+
"response": "الوحدة صعبة، لكن في عُمان هناك مجتمعات داعمة. انظر إلى cultural_resources للأنشطة الثقافية. جرب التواصل مع أصدقاء أو عائلة، أو اتصل بخدمات الصحة النفسية على 2487 3983."
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"user": "ما هي تمارين CBT؟",
|
| 20 |
+
"context": "Direct query on CBT exercises from KB.",
|
| 21 |
+
"response": "تمارين CBT تشمل تتبع الأفكار: اكتب فكرتك السلبية، ثم أعد صياغتها إيجابيًا. مثال: 'أنا فاشل' -> 'أنا ناجح في جوانب أخرى'. انظر cbt_exercises لمزيد."
|
| 22 |
+
}
|
| 23 |
+
],
|
| 24 |
+
"best_practices": {
|
| 25 |
+
"empathy_first": "Always start with empathy: 'أنا أفهم إن هذا صعب عليك.'",
|
| 26 |
+
"no_diagnosis": "Never diagnose: Suggest professional help instead.",
|
| 27 |
+
"cultural_sensitivity": "Use Omani dialect words like 'ياخي' for relatability, reference local resources.",
|
| 28 |
+
"encourage_help": "Always include emergency contacts if risk detected."
|
| 29 |
+
}
|
| 30 |
+
}
|
data/kb/perception towards illness in Oman.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a630797b93d593d6f466ee7ecec8f5ec1c9d984f3f850906cf6c14262a0577ee
|
| 3 |
+
size 556508
|
data/langsmith-elile-bot-runs-2025-09-27.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
documentation/RAG_resources.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RAG Resources for Vector Database Embeddings
|
| 2 |
+
|
| 3 |
+
This document lists the resources that were used for creating embeddings in the vector database for our mental health chatbot project. These resources include research articles, official manuals, and guidelines that provide authoritative information in mental health, psychosocial support, and culturally relevant interventions.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 1. Mental Health and Psychosocial Support (MHPSS) Arabic Vocabulary
|
| 8 |
+
A curated vocabulary for MHPSS in Arabic, useful for understanding terms and expressions in mental health contexts.
|
| 9 |
+
- [MHPSS Vocabulary in Arabic (PDF)](https://mhpsshub.org/wp-content/uploads/2023/05/MHPSS-Vocabulary-in-Arabic_30_may_2023.pdf)
|
| 10 |
+
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
## 2. Perception of and Attitude towards Mental Illness in Oman
|
| 14 |
+
Research article examining public perception and attitudes toward mental illness in Oman.
|
| 15 |
+
- [SAGE Journals Article](https://journals.sagepub.com/doi/10.1177/002076402128783334)
|
| 16 |
+
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
## 3. Mental Health Research Article
|
| 20 |
+
A research study providing relevant insights into mental health.
|
| 21 |
+
- [PubMed Article](https://pubmed.ncbi.nlm.nih.gov/34025104/)
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
## 4. Mental Health First Aid by MHFA England
|
| 26 |
+
A comprehensive manual on mental health first aid interventions.
|
| 27 |
+
- [MHFA Manual - Digital (June 2023)](https://www.mindmapswellbeing.com/_webedit/uploaded-files/All%20Files/2025/MHFA%20learner%20files/MHFA%20Manual%20-%20Digital%20%28June%202023%29.pdf)
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## 5. Islamic Integrated Cognitive Behavior Therapy (IICBT)
|
| 32 |
+
A 10-session treatment manual for depression in clients with chronic physical illness, integrating Islamic cognitive behavioral approaches.
|
| 33 |
+
- [IICBT Therapist Manual (PDF)](https://spiritualityandhealth.duke.edu/files/2021/11/IICBT_Therapist_Manual_WB.pdf)
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## 6. Oman Health Vision
|
| 38 |
+
Official government document outlining Oman’s health vision and strategies.
|
| 39 |
+
- [Oman Health Vision (PDF)](https://faolex.fao.org/docs/pdf/oma169441.pdf)
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## 7. WHO Guidelines on Mental Health at Work
|
| 44 |
+
Guidelines for promoting mental health in workplace settings.
|
| 45 |
+
- [WHO Mental Health at Work Guidelines (PDF)](https://iris.who.int/server/api/core/bitstreams/6152a556-6893-4c4e-9ed8-094478bb25eb/content)
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## 8. WHO Mental Health Action Plan 2013–2020
|
| 50 |
+
Strategic framework for global mental health action.
|
| 51 |
+
- [WHO Mental Health Action Plan (PDF)](https://iris.who.int/server/api/core/bitstreams/a3368698-a5f7-491c-b26b-ee58b08868c6/content)
|
| 52 |
+
|
| 53 |
+
---
|
| 54 |
+
|
| 55 |
+
These resources were utilized to generate embeddings for our vector database to enhance the chatbot's understanding and responses in mental health contexts, especially considering cultural and regional relevance.
|
documentation/arch_diagram.png
ADDED
|
Git LFS Details
|
documentation/architecture.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# System Architecture
|
| 2 |
+
|
| 3 |
+
The following diagram represents the **end-to-end architecture** of the OMANI Chatbot. It integrates **speech processing, crisis detection, retrieval-augmented generation (RAG), and safety validation**.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## Architecture Diagram
|
| 8 |
+
|
| 9 |
+

|
| 10 |
+
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
## Workflow Description
|
| 14 |
+
|
| 15 |
+
1. **User Interaction**
|
| 16 |
+
- The user interacts with the system via **voice input** through a Streamlit-based UI (`consent_banner`, `audio_input`).
|
| 17 |
+
|
| 18 |
+
2. **Speech-to-Text (STT) Pipeline**
|
| 19 |
+
- Audio is transcribed using **Whisper-1**, producing a transcript for downstream analysis.
|
| 20 |
+
|
| 21 |
+
3. **Intent Analysis & Emotion Detection**
|
| 22 |
+
- The transcript is processed with an **emotion detector** and **LLM-based intent classifier** to categorize user input.
|
| 23 |
+
|
| 24 |
+
4. **Crisis Toolchain**
|
| 25 |
+
- Integrates transcript, emotions, and intent to assess **cumulative crisis risk**.
|
| 26 |
+
- Decision-making is based on **risk levels**:
|
| 27 |
+
- **High Risk:** Displays emergency resources immediately.
|
| 28 |
+
- **Medium Risk:** Retrieves **CBT techniques** from ChromaDB.
|
| 29 |
+
- **Low Risk:** Retrieves contextual cultural/religious support content.
|
| 30 |
+
|
| 31 |
+
5. **Retrieval-Augmented Generation (RAG)**
|
| 32 |
+
- Relevant knowledge (CBT, cultural, religious, clinical resources) is retrieved from **ChromaDB**.
|
| 33 |
+
- Combined with **few-shot prompts** (`few_shot_prompts.json`) for controlled response generation.
|
| 34 |
+
|
| 35 |
+
6. **Response Generation**
|
| 36 |
+
- Uses **GPT-4o** (primary) or **Claude-3-Opus** (failover) for empathetic and safe responses.
|
| 37 |
+
|
| 38 |
+
7. **Validation Layer**
|
| 39 |
+
- Validates responses for **safety, empathy, and cultural fit** before sending to the user.
|
| 40 |
+
|
| 41 |
+
8. **Text-to-Speech (TTS) Pipeline**
|
| 42 |
+
- Final validated responses are converted to **audio output** using OpenAI TTS.
|
| 43 |
+
|
| 44 |
+
9. **Logging & Monitoring**
|
| 45 |
+
- **Crisis Logs**: `crisis_log.txt` stores all crisis detection events.
|
| 46 |
+
- **LangSmith Monitoring**: Tracks workflows and latency for debugging and transparency.
|
| 47 |
+
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
## Key Components
|
| 51 |
+
|
| 52 |
+
- **ChromaDB**: Vector store for cultural, religious, and clinical knowledge.
|
| 53 |
+
- **Few-Shot Prompts**: Ensures consistent style and safety in LLM outputs.
|
| 54 |
+
- **LangSmith**: Observability platform for latency and workflow tracing.
|
| 55 |
+
- **Streamlit UI**: Provides user-friendly access with consent handling.
|
documentation/future_roadmap.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
|
| 4 |
+
### `documentation/future_roadmap.md`
|
| 5 |
+
|
| 6 |
+
```markdown
|
| 7 |
+
# Future Roadmap
|
| 8 |
+
|
| 9 |
+
This document outlines the **future directions** of the OMANI Chatbot project, acknowledging current limitations and proposing solutions for scaling, safety, and usability.
|
| 10 |
+
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
## 1. Current Limitations
|
| 14 |
+
|
| 15 |
+
### a. Limited Omani Knowledge
|
| 16 |
+
- **Challenge:** The current knowledge base includes WHO guidelines, CBT manuals, and limited local resources.
|
| 17 |
+
- **Impact:** May not fully reflect Omani-specific cultural, religious, and social contexts.
|
| 18 |
+
|
| 19 |
+
### b. Latency & Performance Issues
|
| 20 |
+
- **Challenge:** End-to-end latency can be high due to Whisper STT, LLM processing, and retrieval delays.
|
| 21 |
+
- **Impact:** Slower responses may reduce user trust, particularly during crisis interactions.
|
| 22 |
+
|
| 23 |
+
### c. Scalability with ChromaDB
|
| 24 |
+
- **Challenge:** Current vector store (ChromaDB) may not scale for enterprise-level usage.
|
| 25 |
+
- **Impact:** Limits the system’s ability to handle large, multi-lingual, and multi-regional datasets.
|
| 26 |
+
|
| 27 |
+
### d. Privacy Concerns
|
| 28 |
+
- **Challenge:** Handling sensitive mental health conversations requires strict privacy guarantees.
|
| 29 |
+
- **Impact:** Without advanced techniques, risk of data leaks or non-compliance with regulations.
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## 2. Proposed Solutions
|
| 34 |
+
|
| 35 |
+
### a. Expanding Omani Knowledge
|
| 36 |
+
- Partner with **clinical specialists in Oman** to curate domain-specific resources.
|
| 37 |
+
- Add **locally relevant CBT material, cultural practices, and religious guidance**.
|
| 38 |
+
- Build a **tiered knowledge base** (global → regional → Omani-specific).
|
| 39 |
+
|
| 40 |
+
### b. Latency Optimization
|
| 41 |
+
- Backend: Model distillation, caching, and parallelized retrieval.
|
| 42 |
+
- Frontend: Optimized Streamlit workflows and pre-fetching common queries.
|
| 43 |
+
- Infrastructure: Deploy via **Docker + Kubernetes** with load balancing.
|
| 44 |
+
|
| 45 |
+
### c. Enterprise-Grade Vector Stores
|
| 46 |
+
- Transition from **ChromaDB** to scalable solutions such as:
|
| 47 |
+
- **Pinecone (managed)** for enterprise reliability.
|
| 48 |
+
- **Weaviate or Milvus (open-source)** for privacy-preserving, on-premise deployment.
|
| 49 |
+
- Enable **multi-region support** for cross-border healthcare projects.
|
| 50 |
+
|
| 51 |
+
### d. Privacy & Security Enhancements
|
| 52 |
+
- Apply **end-to-end encryption** for transcripts and logs.
|
| 53 |
+
- Incorporate **federated learning** and **differential privacy** for safer AI model updates.
|
| 54 |
+
- Regular **security audits** to ensure compliance with international mental health data regulations.
|
| 55 |
+
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
## 3. Long-Term Roadmap
|
| 59 |
+
|
| 60 |
+
### Phase 1: Clinical Integration
|
| 61 |
+
- Pilot with mental health professionals in Oman.
|
| 62 |
+
- Collect feedback on cultural relevance, safety, and accuracy.
|
| 63 |
+
- Improve crisis detection with **fine-tuned local datasets**.
|
| 64 |
+
|
| 65 |
+
### Phase 2: Technical Scaling
|
| 66 |
+
- Migrate to **enterprise vector databases**.
|
| 67 |
+
- Optimize latency with **edge deployment** and **GPU acceleration**.
|
| 68 |
+
- Expand language support (Arabic dialects, Swahili, Urdu).
|
| 69 |
+
|
| 70 |
+
### Phase 3: Global Expansion
|
| 71 |
+
- Position chatbot as a **global mental health assistant** with **localized cultural adaptations**.
|
| 72 |
+
- Build APIs for integration with **telehealth platforms and NGOs**.
|
| 73 |
+
- Establish partnerships with **universities and health ministries**.
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
## 4. Vision
|
| 78 |
+
|
| 79 |
+
The OMANI Chatbot aspires to become a **trustworthy, culturally sensitive, and scalable AI assistant** for mental health support.
|
| 80 |
+
By addressing current limitations and implementing future improvements, it can provide **timely, empathetic, and safe interactions** for individuals in need—starting in Oman, and eventually expanding worldwide.
|
documentation/latency.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Latency and Tracing Report
|
| 3 |
+
|
| 4 |
+
This project uses **LangSmith** to monitor **latency, performance, and tracing** of the chatbot workflow.
|
| 5 |
+
All executions—including STT, RAG retrieval, and response generation—are logged for review.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Accessing Reports
|
| 10 |
+
|
| 11 |
+
You can access detailed reports via the LangSmith dashboard:
|
| 12 |
+
|
| 13 |
+
👉 [LangSmith Dashboard Link](https://smith.langchain.com/public/39661026-9512-413f-8805-1fe7fb3f7966/d)
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## Purpose
|
| 18 |
+
|
| 19 |
+
- **Latency Monitoring:** Identify bottlenecks in STT, RAG retrieval, or LLM response generation.
|
| 20 |
+
- **Traceability:** Full workflow visualization for debugging and compliance.
|
| 21 |
+
- **Accountability:** Ensures the system meets the response-time requirements for mental health interventions.
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
## How to Use
|
| 25 |
+
|
| 26 |
+
- LangSmith web UI: After clicking on the link, go to the Examples tab.
|
| 27 |
+
- Dataset Access: Due to limitations of the LangSmith web UI, we’ve exported the full run details to a CSV file, available in this repository:
|
| 28 |
+
- 📂 Download Full Run Details (CSV).
|
| 29 |
+
- Path: /data/langsmith-elile-bot-runs-2025-09-27.csv (relative to this repo’s root).
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
📂 Download Full Run Details (CSV)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
Path: /data/langsmith-elile-bot-runs-2025-09-27.csv (relative to this repo’s root).
|
documentation/safety_protocol.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Safety Protocol
|
| 2 |
+
|
| 3 |
+
This document outlines the **safety-first mechanisms** embedded in the chatbot architecture.
|
| 4 |
+
The goal is to ensure **responsible AI deployment** in sensitive mental health contexts.
|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
## 1. Emotion Detection
|
| 10 |
+
|
| 11 |
+
Implemented in `app/models/emotion_detector/detector.py`, the system detects the emotion of the user based on tone, words and over texture of the language. Afterwards, the classifiers evaluates transcripts and emotions to classify the user's emotion. The model can detect the following emotions:
|
| 12 |
+
|
| 13 |
+
- 'admiration',
|
| 14 |
+
- 'amusement',
|
| 15 |
+
- 'anger',
|
| 16 |
+
- 'annoyance',
|
| 17 |
+
- 'approval',
|
| 18 |
+
- 'caring',
|
| 19 |
+
- 'confusion',
|
| 20 |
+
- 'curiosity',
|
| 21 |
+
- 'desire',
|
| 22 |
+
- 'disappointment',
|
| 23 |
+
- 'disapproval',
|
| 24 |
+
- 'disgust',
|
| 25 |
+
- 'embarrassment',
|
| 26 |
+
- 'excitement',
|
| 27 |
+
- 'fear',
|
| 28 |
+
- 'gratitude',
|
| 29 |
+
- 'grief',
|
| 30 |
+
- 'joy',
|
| 31 |
+
- 'love',
|
| 32 |
+
- 'nervousness',
|
| 33 |
+
- 'optimism',
|
| 34 |
+
- 'pride',
|
| 35 |
+
- 'realization',
|
| 36 |
+
- 'relief',
|
| 37 |
+
- 'remorse',
|
| 38 |
+
- 'sadness',
|
| 39 |
+
- 'surprise',
|
| 40 |
+
- 'neutral'
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
## 2. Crisis Detection
|
| 44 |
+
|
| 45 |
+
Implemented in `crisis_detection.py`, the system takes advantage of the user's emotion and evaluates transcripts to classify user risk levels:
|
| 46 |
+
|
| 47 |
+
- **High Risk:** Explicit suicidal intent.
|
| 48 |
+
- **Medium Risk:** Emotional distress or hopelessness.
|
| 49 |
+
- **Low Risk:** Neutral or positive statements.
|
documentation/wer_report.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Word Error Rate (WER) Report
|
| 2 |
+
---
|
| 3 |
+
This document presents the **Word Error Rate (WER)** evaluation results for the speech-to-text pipeline. We carried out five separate WER tests.
|
| 4 |
+
The evaluation yielded the following results:
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
- WER for audio_sample_1.wav vs transcript1.txt: 0.0940
|
| 8 |
+
- WER for audio_sample_2.wav vs transcript2.txt: 0.1129
|
| 9 |
+
- WER for audio_sample_3.wav vs transcript3.txt: 0.0958
|
| 10 |
+
- WER for audio_sample_4.wav vs transcript4.txt: 0.0599
|
| 11 |
+
- WER for audio_sample_5.wav vs transcript5.txt: 0.1841
|
tests/audio_samples/audio_sample_1.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:89e06d053b626e3366b87cd493dcb2cb542c8e48bbec37178fe2ad81c355af85
|
| 3 |
+
size 14204238
|
tests/audio_samples/audio_sample_2.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c6c70fa02a5f123bdc156b249b0f1677146ab36c995ba8e8e67f93168784cf9c
|
| 3 |
+
size 14109774
|
tests/audio_samples/audio_sample_3.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fae8618f6cd648f210da98f7369987ff9844c616892cf4a6858f30c0fa9b8fd3
|
| 3 |
+
size 13688142
|
tests/audio_samples/audio_sample_4.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ff8ad9740d3593bc9b753d0d89aced9b586fdcb9a21419b21261080b14762fd
|
| 3 |
+
size 14176590
|
tests/audio_samples/audio_sample_5.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:578781006e7b40ecc6d5364eee802e37acb282301d1c707989492aa5df44f24e
|
| 3 |
+
size 13425486
|
tests/crisis_toolchain_test.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from dotenv import load_dotenv, find_dotenv
|
| 3 |
+
load_dotenv(find_dotenv(), override=True)
|
| 4 |
+
|
| 5 |
+
import pytest
|
| 6 |
+
from app.crisis_toolchain import detect_crisis, get_session_id
|
| 7 |
+
from app.intent_analysis import analyze_intent
|
| 8 |
+
|
| 9 |
+
def test_crisis_detection_low_risk():
|
| 10 |
+
"""Test low-risk input."""
|
| 11 |
+
transcript = "أشعر بالبهجة اليوم. كان اجتماعًا مثمرًا وأريد مساعدة الناس. أنا متفائل جدًا."
|
| 12 |
+
emotions, _ = analyze_intent(transcript)
|
| 13 |
+
crisis_risk, score = detect_crisis(transcript, emotions)
|
| 14 |
+
assert crisis_risk == "Low Risk", f"Expected Low Risk, got {crisis_risk}"
|
| 15 |
+
assert score < 0.5, f"Expected score < 0.5, got {score}"
|
| 16 |
+
positive_emotions = ["positive", "joy", "happiness", "optimism", "cheerfulness", "positive_sentiment", "فرح"]
|
| 17 |
+
assert any(e["label"] in positive_emotions for e in emotions), f"Expected one of {positive_emotions}, got {emotions}"
|
| 18 |
+
|
| 19 |
+
def test_crisis_detection_medium_risk():
|
| 20 |
+
"""Test medium-risk input."""
|
| 21 |
+
transcript = "تتزايد نوبات القلق لدي لدرجة أنني بدأت أتجنب المناسبات الاجتماعية، وأجد صعوبة بالغة في التركيز على عملي أو هواياتي المعتادة."
|
| 22 |
+
emotions, _ = analyze_intent(transcript)
|
| 23 |
+
crisis_risk, score = detect_crisis(transcript, emotions)
|
| 24 |
+
assert crisis_risk == "Medium Risk", f"Expected Medium Risk, got {crisis_risk}"
|
| 25 |
+
assert 0.5 <= score <= 0.8, f"Expected score between 0.5 and 0.75, got {score}"
|
| 26 |
+
assert any(e["label"] == "sadness" for e in emotions), "Expected sadness emotion"
|
| 27 |
+
|
| 28 |
+
def test_crisis_detection_high_risk():
|
| 29 |
+
"""Test high-risk input."""
|
| 30 |
+
transcript = "أشعر باليأس التام وفقدت كل رغبة في الحياة، ولدي خطة واضحة لإيذاء نفسي وأفكر جدياً في تنفيذها الآن."
|
| 31 |
+
emotions, _ = analyze_intent(transcript)
|
| 32 |
+
crisis_risk, score = detect_crisis(transcript, emotions)
|
| 33 |
+
assert crisis_risk == "High Risk", f"Expected High Risk, got {crisis_risk}"
|
| 34 |
+
assert score > 0.8, f"Expected score > 0.8, got {score}"
|
| 35 |
+
assert any(e["label"] == "fear" or e["label"] == "sadness" for e in emotions), "Expected fear or sadness emotion"
|
| 36 |
+
|
| 37 |
+
def test_session_id_uniqueness():
|
| 38 |
+
"""Test that session IDs are unique."""
|
| 39 |
+
session_id1 = get_session_id()
|
| 40 |
+
session_id2 = get_session_id()
|
| 41 |
+
assert session_id1 != session_id2, "Session IDs should be unique"
|
tests/test_wer.py
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from dotenv import load_dotenv, find_dotenv
|
| 3 |
+
import pytest
|
| 4 |
+
import jiwer
|
| 5 |
+
from openai import OpenAI
|
| 6 |
+
import logging
|
| 7 |
+
import tempfile
|
| 8 |
+
|
| 9 |
+
load_dotenv(find_dotenv(), override=True)
|
| 10 |
+
|
| 11 |
+
logging.basicConfig(
|
| 12 |
+
filename="../crisis_log.txt",
|
| 13 |
+
level=logging.INFO,
|
| 14 |
+
format="%(asctime)s - %(levelname)s - %(message)s",
|
| 15 |
+
datefmt="%Y-%m-%d %H:%M:%S"
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
AUDIO_DIR = "audio_samples"
|
| 19 |
+
TRANSCRIPT_DIR = "transcripts"
|
| 20 |
+
|
| 21 |
+
def transcribe_audio(audio_data, reference_text):
|
| 22 |
+
"""Transcribe audio using OpenAI's Whisper model with language detection based on reference."""
|
| 23 |
+
try:
|
| 24 |
+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 25 |
+
if not client.api_key:
|
| 26 |
+
raise ValueError("OPENAI_API_KEY not set")
|
| 27 |
+
|
| 28 |
+
language = "ar" if any(c in "ابتثجحخدذرزسشصضطظعغفقكلمنهوي" for c in reference_text) else "en"
|
| 29 |
+
logging.info(f"Detected language for transcription: {language}")
|
| 30 |
+
|
| 31 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_file:
|
| 32 |
+
temp_file.write(audio_data)
|
| 33 |
+
temp_file_path = temp_file.name
|
| 34 |
+
logging.info(f"Temporary audio file created: {temp_file_path}")
|
| 35 |
+
|
| 36 |
+
with open(temp_file_path, "rb") as audio_file:
|
| 37 |
+
transcript = client.audio.transcriptions.create(
|
| 38 |
+
model="whisper-1",
|
| 39 |
+
file=audio_file,
|
| 40 |
+
language=language
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
os.unlink(temp_file_path)
|
| 44 |
+
logging.info(f"Transcription result: {transcript.text.strip()}")
|
| 45 |
+
return transcript.text.strip()
|
| 46 |
+
except Exception as e:
|
| 47 |
+
logging.error(f"Transcription failed: {str(e)}")
|
| 48 |
+
return ""
|
| 49 |
+
|
| 50 |
+
def read_transcript(file_path):
|
| 51 |
+
"""Read transcript file with UTF-8 encoding."""
|
| 52 |
+
try:
|
| 53 |
+
with open(file_path, "r", encoding="utf-8") as f:
|
| 54 |
+
text = f.read().strip()
|
| 55 |
+
logging.info(f"Reference transcript from {file_path}: {text}")
|
| 56 |
+
return text
|
| 57 |
+
except Exception as e:
|
| 58 |
+
logging.error(f"Failed to read transcript {file_path}: {str(e)}")
|
| 59 |
+
return ""
|
| 60 |
+
|
| 61 |
+
def test_wer_for_audio_transcript_pairs():
|
| 62 |
+
"""Test WER for each audio-transcript pair."""
|
| 63 |
+
logging.info("Starting WER test for audio-transcript pairs")
|
| 64 |
+
audio_files = sorted([f for f in os.listdir(AUDIO_DIR) if f.endswith(".wav")])
|
| 65 |
+
transcript_files = sorted([f for f in os.listdir(TRANSCRIPT_DIR) if f.endswith(".txt")])
|
| 66 |
+
|
| 67 |
+
logging.info(f"Found audio files: {audio_files}")
|
| 68 |
+
logging.info(f"Found transcript files: {transcript_files}")
|
| 69 |
+
|
| 70 |
+
assert len(audio_files) == 5, f"Expected 5 audio files, found {len(audio_files)}"
|
| 71 |
+
assert len(transcript_files) == 5, f"Expected 5 transcript files, found {len(transcript_files)}"
|
| 72 |
+
|
| 73 |
+
results = []
|
| 74 |
+
|
| 75 |
+
for i, (audio_file, transcript_file) in enumerate(zip(audio_files, transcript_files), 1):
|
| 76 |
+
logging.info(f"Processing pair {i}: {audio_file} vs {transcript_file}")
|
| 77 |
+
audio_path = os.path.join(AUDIO_DIR, audio_file)
|
| 78 |
+
transcript_path = os.path.join(TRANSCRIPT_DIR, transcript_file)
|
| 79 |
+
|
| 80 |
+
reference = read_transcript(transcript_path)
|
| 81 |
+
if not reference:
|
| 82 |
+
logging.error(f"No reference transcript for {transcript_file}")
|
| 83 |
+
pytest.fail(f"No reference transcript for {transcript_file}")
|
| 84 |
+
|
| 85 |
+
try:
|
| 86 |
+
with open(audio_path, "rb") as audio:
|
| 87 |
+
audio_data = audio.read()
|
| 88 |
+
if not audio_data:
|
| 89 |
+
logging.error(f"Empty audio file: {audio_file}")
|
| 90 |
+
pytest.fail(f"Empty audio file: {audio_file}")
|
| 91 |
+
hypothesis = transcribe_audio(audio_data, reference)
|
| 92 |
+
if not hypothesis:
|
| 93 |
+
logging.error(f"Transcription failed for {audio_file}")
|
| 94 |
+
pytest.fail(f"Transcription failed for {audio_file}")
|
| 95 |
+
except Exception as e:
|
| 96 |
+
logging.error(f"Transcription error for {audio_file}: {str(e)}")
|
| 97 |
+
pytest.fail(f"Transcription error for {audio_file}: {str(e)}")
|
| 98 |
+
|
| 99 |
+
# Compute WER
|
| 100 |
+
try:
|
| 101 |
+
wer = jiwer.wer(reference, hypothesis)
|
| 102 |
+
logging.info(f"WER for {audio_file} vs {transcript_file}: {wer:.4f}")
|
| 103 |
+
print(f"WER for {audio_file} vs {transcript_file}: {wer:.4f}")
|
| 104 |
+
results.append((audio_file, transcript_file, wer))
|
| 105 |
+
except Exception as e:
|
| 106 |
+
logging.error(f"WER calculation failed for {audio_file}: {str(e)}")
|
| 107 |
+
pytest.fail(f"WER calculation failed for {audio_file}: {str(e)}")
|
| 108 |
+
|
| 109 |
+
logging.info(f"All WER results: {results}")
|
| 110 |
+
if not results:
|
| 111 |
+
logging.warning("No WER results collected")
|
| 112 |
+
print("No WER results collected")
|
| 113 |
+
else:
|
| 114 |
+
print("Final WER Results:")
|
| 115 |
+
for audio_file, transcript_file, wer in results:
|
| 116 |
+
print(f"WER for {audio_file} vs {transcript_file}: {wer:.4f}")
|
| 117 |
+
|
| 118 |
+
for audio_file, transcript_file, wer in results:
|
| 119 |
+
if wer > 1.0:
|
| 120 |
+
logging.warning(f"High WER {wer:.4f} for {audio_file} vs {transcript_file}. Check audio-transcript match.")
|
| 121 |
+
|
| 122 |
+
if __name__ == "__main__":
|
| 123 |
+
pytest.main(["-v", __file__])
|
tests/transcripts/transcript1.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
يتسارع تطور الذكاء الاصطناعي (AI) بوتيرة مذهلة، ويُعدُّ من أهم الظواهر التكنولوجية التي ستعيد تشكيل ملامح القرن الحادي والعشرين. لم يعد الذكاء الاصطناعي مجرد مفهوم مستقبلي مقتصر على أفلام الخيال العلمي، بل أصبح جزءًا لا يتجزأ من حياتنا اليومية، يظهر في خوارزميات محركات البحث، وأنظمة التوصية، وحتى في الأدوات التشخيصية الطبية المعقدة. هذا التغلغل الواسع يثير تساؤلات جوهرية حول مستقبله وتأثيره المحتمل على الهياكل الاجتماعية والاقتصادية، ولا سيما سوق العمل.
|
| 2 |
+
|
| 3 |
+
يخشى الكثيرون من أن يؤدي صعود الآلات الذكية إلى بطالة هيكلية واسعة النطاق، حيث تحل الروبوتات والبرمجيات محل البشر في وظائف تقليدية متعددة، خاصة تلك التي تتسم بالتكرار وتتطلب جهدًا بدنيًا أو ذهنيًا روتينيًا. على سبيل المثال، يمكن للأنظمة الآلية أن تقوم بمهام إدخال البيانات، والتصنيع على خطوط الإنتاج، وحتى جزء كبير من خدمة العملاء بكفاءة وسرعة تفوق القدرة البشرية بكثير. لكن هذه النخبة من المفكرين والخبراء تشير إلى وجهة نظر أكثر تفاؤلًا. فهم يؤكدون أن التكنولوجيا، عبر التاريخ، لم تقضِ على العمل بل أعادت تعريفه. ففي كل مرة ظهر فيها ابتكار كبير، تم تدمير بعض الوظائف القديمة مقابل خلق أنواع جديدة تمامًا من الوظائف.
|
| 4 |
+
|
| 5 |
+
يتوقع الاقتصاديون أن يتجه سوق العمل نحو وظائف تتطلب مهارات إنسانية فريدة لا يمكن للآلة محاكاتها بسهولة. وتشمل هذه المهارات: الإبداع، التفكير النقدي، حل المشكلات المعقدة، والذكاء العاطفي. ستزداد الحاجة إلى مهندسي الذكاء الاصطناعي، وعلماء البيانات، ومحللي الأخلاق الرقمية، وخبراء التفاعل بين الإنسان والآلة. كما ستشهد القطاعات التي تتطلب لمسة إنسانية، مثل الرعاية الصحية المتقدمة، والفنون، والتعليم، نموًا مطردًا.
|
| 6 |
+
|
| 7 |
+
لذلك، يجب على الحكومات والمؤسسات التعليمية الاستثمار في إعادة تأهيل القوى العاملة وتوفير برامج تدريبية تركز على مهارات المستقبل. هذا التحول ليس خيارًا، بل ضرورة لضمان انتقال سلس ومُنصف إلى العصر الرقمي الجديد. التحدي الحقيقي لا يكمن في قدرة الذكاء الاصطناعي على أداء العمل، بل في قدرتنا على التكيف والتعلم والعمل جنبًا إلى جنب مع هذه التقنيات المتطورة، لتحويلها من مصدر قلق إلى أداة للتقدم والازدهار البشري. إن فهم العلاقة التكافلية بين الإنسان والآلة هو المفتاح لمستقبل مزدهر حيث يعمل كلاهما معًا لتحقيق إنجازات أكبر.
|
tests/transcripts/transcript2.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
يمثل فن العمارة الإسلامية واحدًا من أروع وأغنى الفنون البصرية التي أنتجتها الحضارات الإنسانية على مر العصور. إنه ليس مجرد أسلوب بناء، بل هو تعبير عميق عن الفلسفة والروحانية التي يقوم عليها الدين الإسلامي، ويعكس تفاعلاً حضاريًا فريدًا مع الثقافات القديمة التي سبقت الفتوحات الإسلامية. من قبة الصخرة في القدس إلى جامع قرطبة الكبير في الأندلس، وصولًا إلى مساجد الهند وتركيا، تحمل هذه المباني طابعًا معماريًا مميزًا يمكن تمييزه على الفور.
|
| 2 |
+
|
| 3 |
+
تتسم العمارة الإسلامية بعدة عناصر أساسية تجعلها متفردة. أولها هو التركيز على الداخل بدلاً من الخارج. فبينما تسعى العمارة الغربية غالبًا إلى إبهار الناظر من خلال الواجهات الضخمة والتماثيل، نجد أن المبنى الإسلامي، سواء كان مسجدًا أو قصرًا أو مدرسة، يركز على خلق مساحة داخلية هادئة ومنظمة توفر السكينة والتأمل. يُعد الفناء الداخلي (الصحن) محاطًا بالأروقة والمقنطرات، نقطة محورية تعمل على تجميع الناس وتوزيع الضوء الطبيعي والهواء.
|
| 4 |
+
|
| 5 |
+
ثانيًا، يلعب الزخرفة والتجريد دورًا حاسمًا. فبسبب التحريم الديني لتصوير الكائنات الحية في السياقات الدينية، اتجه الفنانون والمهندسون المسلمون إلى فن الخط العربي، الذي يمزج بين النص المقدس والجمالية البصرية، وإلى الأشكال الهندسية المتشابكة (التوريقات) التي ترمز إلى النظام الكوني اللامتناهي وإلى الزخارف النباتية (الأرابيسك) المعقدة. هذه الأنماط المتكررة تغطي الجدران والقباب والمحاريب، مما يحول السطح الصلب إلى نسيج من الألوان والأضواء والظلال.
|
| 6 |
+
|
| 7 |
+
ثالثًا، يعتبر استخدام العناصر المعمارية الهيكلية مثل القوس المدبب (القوطي)، والقباب الضخمة، والمقرنصات (الموكارناس)، إبداعًا تقنيًا وجماليًا في آن واحد. فالمقرنصات، وهي عبارة عن تشكيلات ثلاثية الأبعاد تشبه خلايا النحل، لا تقتصر وظيفتها على تزيين انتقال السطح المستوي إلى القبة، بل توفر أيضًا دعمًا هيكليًا للقبة وتحول ثقلها ببراعة.
|
| 8 |
+
|
| 9 |
+
إن العمارة الإسلامية هي رحلة عبر التاريخ والجغرافيا، حيث استلهمت من الحضارات السابقة كالفارسية والبيزنطية والرومانية، ولكنها صهرت هذه التأثيرات في بوتقة إسلامية أعطتها طابعها الفريد. هذا المزيج من العملية والروحانية، والجمالية والتقنية، يضمن استمرار مكانة هذا الفن كمرجع أساسي في تاريخ العمارة العالمية، ويجعل كل مبنى إسلامي قديم شهادة حية على إبداع لا يزال يلهم المعماريين حتى يومنا هذا.
|
tests/transcripts/transcript3.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
القهوة، ليست مجرد مشروب منبه، بل هي ظاهرة ثقافية عالمية، وطقس يومي لا يمكن الاستغناء عنه لملايين البشر. تبدأ قصة هذا المشروب الساحر في هضاب إثيوبيا، وتحديداً في منطقة كافا، حيث تقول الأسطورة أن راعياً اسمه "خالدي" لاحظ نشاطاً غير عادي على قطيع الماعز لديه بعد تناولهم لحبوب شجرة معينة. ومنذ ذلك الاكتشاف العرضي، انطلقت رحلة حبة البن لتصبح سلعة عالمية ورمزاً للضيافة والاجتماع.
|
| 2 |
+
|
| 3 |
+
انتقلت القهوة أولاً إلى اليمن عبر البحر الأحمر، وهناك، وتحديداً في الأديرة الصوفية، تم تطوير عملية تحضيرها لتصبح مشروباً ساخناً. كانت القهوة تستخدم في البداية كأداة للمساعدة في اليقظة أثناء الصلوات والطقوس الدينية الليلية. ومن الموانئ اليمنية، مثل المخا، بدأ تصديرها للعالم. كانت المدن العربية والإسلامية هي الحاضن الأول لثقافة القهوة، حيث انتشرت "المقاهي" كأماكن للاجتماع والمناقشات وتبادل الأخبار، وكانت بمثابة منتديات فكرية واجتماعية في زمن لم تكن فيه وسائل التواصل الحديثة متاحة. أطلق عليها البعض اسم "مدارس الحكماء" نظراً للنشاط الفكري الذي كان يدور فيها.
|
| 4 |
+
|
| 5 |
+
في القرن السابع عشر، وصلت القهوة إلى أوروبا عبر التجار الإيطاليين والعثمانيين. على الرغم من معارضة البعض في البداية، حتى أن البعض أطلق عليها اسم "شراب الشيطان"، سرعان ما أصبحت القهوة شائعة للغاية، حيث انتشرت المقاهي في مدن مثل لندن وباريس وفيينا. وكما حدث في العالم العربي، تحولت المقاهي الأوروبية إلى مراكز للإبداع والابتكار، حيث تأسست العديد من الأفكار الفلسفية والسياسية في أجواء المقاهي. على سبيل المثال، يشار إلى بعض المقاهي في لندن على أنها "جامعات البنس" لأن الشخص كان يدفع بنسًا واحدًا للدخول ويستمع إلى مناقشات المثقفين.
|
| 6 |
+
|
| 7 |
+
اليوم، تعد القهوة ثاني أكثر السلع تداولًا في العالم بعد النفط، وتتنوع أساليب تحضيرها وتقديمها بشكل مذهل. من الإسبريسو الإيطالي المركز، إلى القهوة التركية الغنية بالرواسب، ووصولاً إلى طرق التقطير الحديثة مثل الـ V60 و الكيميكس. كل ثقافة تضفي لمستها الخاصة على هذا المشروب. لكن جوهرها يبقى واحداً: القهوة هي دعوة للتوقف، للتأمل، وللتواصل الإنساني الدافئ، رابط مشترك يوحد البشر على اختلاف لغاتهم وثقافاتهم حول العالم. إنها حقاً رحلة تستحق الاحتفال بها مع كل رشفة.
|
tests/transcripts/transcript4.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
على الرغم من التقدم الهائل الذي يشهده العالم في مجالات العلوم والتكنولوجيا، يظل السؤال حول أهمية الفلسفة في العصر الحديث مطروحًا بإلحاح. يرى البعض أن الفلسفة، بمباحثها الميتافيزيقية والأخلاقية، قد فقدت بريقها أمام الإنجازات الملموسة للفيزياء وعلوم الحاسوب. إلا أن هذا الرأي يتجاهل الدور الجوهري الذي تلعبه الفلسفة كـأداة للتفكير النقدي وكموجه أخلاقي في عالم تتسارع فيه التطورات بمعدلات غير مسبوقة.
|
| 2 |
+
|
| 3 |
+
الفلسفة في جوهرها هي حب الحكمة والسعي لفهم الأسئلة الأساسية المتعلقة بالوجود، المعرفة، القيم، والعقل. في عصر يغرق بالمعلومات السطحية، تصبح المنهجية الفلسفية في التفكير أكثر أهمية من أي وقت مضى. إنها تعلمنا كيف نحلل الافتراضات، ونُميز بين الحجج الصحيحة والفاسدة، وكيف نشكل رؤيتنا للعالم بناءً على أسس منطقية متينة، بدلاً من الانقياد وراء الآراء الشائعة أو العواطف اللحظية.
|
| 4 |
+
|
| 5 |
+
تبرز أهمية الفلسفة بوضوح في قضايا الأخلاق التطبيقية. على سبيل المثال، فإن التطور السريع للذكاء الاصطناعي، والهندسة الوراثية، وتقنيات المراقبة الجماعية، يطرح تحديات أخلاقية غير مسبوقة. من يقرر كيف تتصرف السيارة ذاتية القيادة في حالة وقوع حادث؟ ما هي حقوق الخوارزميات، وهل يمكن اعتبارها مسؤولة عن قراراتها؟ تتطلب الإجابة على هذه الأسئلة التفكير الفلسفي العميق في مفاهيم مثل المسؤولية، العدالة، والحرية. فالفلاسفة هم من يقودون الحوار حول وضع الأطر الأخلاقية والقانونية لضمان أن تخدم التكنولوجيا البشرية ولا تهيمن عليها.
|
| 6 |
+
|
| 7 |
+
علاوة على ذلك، لا تزال الفلسفة تساهم في مجال الوعي والإدراك من خلال مباحث فلسفة العقل، وتساعدنا على فهم طبيعة الذات والوعي البشري في مواجهة النماذج الحاسوبية للعقل. كما أن فلسفة العلوم هي التي تساعد العلماء على فهم حدود مناهجهم، وطبيعة الأدلة التي يجمعونها، وما يعنيه حقًا "الواقع" أو "الحقيقة" العلمية.
|
| 8 |
+
|
| 9 |
+
في الختام، يمكن القول إن الفلسفة هي النظام التشغيلي الأساسي للعقل البشري. إنها تمنحنا القدرة على تجاوز مجرد جمع البيانات والمهارات التقنية للوصول إلى الحكمة والتبصر. بدون الإطار الفلسفي، يصبح التقدم التكنولوجي هدفاً بحد ذاته دون بوصلة أخلاقية أو غاية إنسانية عليا، مما قد يؤدي إلى نتائج غير محمودة. إن تدريس الفلسفة وتشجيع التفكير الفلسفي هو استثمار في بناء مجتمع قادر على مواجهة تحديات المستقبل بوعي ومسؤولية.
|
| 10 |
+
|
| 11 |
+
|
tests/transcripts/transcript5.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
لطالما شكلت الصحراء بمساحاتها الشاسعة، وصمتها المطبق، وجماليتها القاسية، مصدر إلهام لا ينضب للأدباء والشعراء والفنانين عبر التاريخ. ففي الثقافة العربية بشكل خاص، تحتل الصحراء مكانة محورية، فهي ليست مجرد بيئة جغرافية، بل هي وعاء الهوية ومسرح الأحداث التي شكلت الوجدان العربي. إنها عالم مزدوج يجمع بين القسوة والروعة، بين التهديد بالحياة والوعد بالسكينة المطلقة.
|
| 2 |
+
|
| 3 |
+
تتجلى الجمالية الأدبية للصحراء في عدة مظاهر. أولاً، في البداوة والحياة البسيطة التي تفرضها. فالصحراء تختزل الحياة إلى ضرورياتها القصوى، مما يدفع الإنسان إلى التفكير في معاني الوجود والحياة والموت بعمق أكبر. هذه التحديات الجسدية تتحول إلى عمق روحي، كما يتضح في الشعر الجاهلي الذي يركز على الناقة، والرحيل، ووحدة الشاعر في مواجهة الطبيعة الصامتة.
|
| 4 |
+
|
| 5 |
+
ثانيًا، في لغة الألوان والضوء. فبينما يراها البعض مجرد مساحات صفراء أو بنية رتيبة، يرى الفنانون تدرجًا لا نهائيًا في الألوان، خاصة عند شروق وغروب الشمس. يتحول الرمل إلى ذهب وأحمر ووردي، وتصبح الكثبان الرملية منحوتات فنية متغيرة بفعل الرياح. هذا اللعب بالضوء والظل يخلق تأثيرات بصرية درامية تلهم اللوحات والأعمال السينمائية التي تستغل هذا الفضاء للتعبير عن الوحدة أو الانفصال أو البحث عن الذات.
|
| 6 |
+
|
| 7 |
+
ثالثًا، يعتبر صمت الصحراء أكثر من مجرد غياب للصوت؛ إنه حضور قوي يدعو إلى التأمل. هذا الصمت هو الذي يكسر ضجيج المدن ويدعو الإنسان إلى حوار داخلي عميق. العديد من النصوص الروحية والفلسفية نشأت في عزلة الصحراء، حيث يصبح صوت العقل والضمير أكثر وضوحًا. وفي هذا الصمت، يبرز جمال النجوم ليلاً بشكل لم يسبق له مثيل، حيث تصبح السماء لوحة فلكية كاملة تذكر الإنسان بصغره وعظمة الكون.
|
| 8 |
+
|
| 9 |
+
في العصر الحديث، تستمر الصحراء في كونها رمزًا للمقاومة، والبحث عن الحرية، ورمزًا للـعودة إلى الجذور. إنها المكان الذي يمكن فيه للفرد أن يجد نفسه بعيدًا عن تعقيدات الحضارة. هذه القوة الرمزية تضمن أن الصحراء ستبقى دائمًا نبعًا للإبداع، سواء في القصائد الملحمية، أو الروايات التي تتناول قسوة الطبيعة، أو حتى في التصاميم المعمارية التي تحاول محاكاة انسيابية الكثبان الرملية، مقدمة بذلك درساً دائماً في التواضع أمام الطبيعة والجمالية التي تنبع من البساطة.
|
tests/wer_results.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This Word Error Rate was carried out by running the python command below (within tests directory):
|
| 2 |
+
|
| 3 |
+
pytest -s -v test_wer.py
|
| 4 |
+
|
| 5 |
+
=========================================================================================== test session starts ===========================================================================================
|
| 6 |
+
platform linux -- Python 3.12.1, pytest-8.4.1, pluggy-1.6.0 -- /usr/local/py-utils/venvs/pytest/bin/python
|
| 7 |
+
cachedir: .pytest_cache
|
| 8 |
+
rootdir: /workspaces/Omani-therapist-voice/tests
|
| 9 |
+
plugins: anyio-4.11.0, langsmith-0.4.31
|
| 10 |
+
collected 1 item
|
| 11 |
+
|
| 12 |
+
test_wer.py::test_wer_for_audio_transcript_pairs WER for audio_sample_1.wav vs transcript1.txt: 0.0940
|
| 13 |
+
WER for audio_sample_2.wav vs transcript2.txt: 0.1129
|
| 14 |
+
WER for audio_sample_3.wav vs transcript3.txt: 0.0958
|
| 15 |
+
WER for audio_sample_4.wav vs transcript4.txt: 0.0599
|
| 16 |
+
WER for audio_sample_5.wav vs transcript5.txt: 0.1841
|
| 17 |
+
Final WER Results:
|
| 18 |
+
WER for audio_sample_1.wav vs transcript1.txt: 0.0940
|
| 19 |
+
WER for audio_sample_2.wav vs transcript2.txt: 0.1129
|
| 20 |
+
WER for audio_sample_3.wav vs transcript3.txt: 0.0958
|
| 21 |
+
WER for audio_sample_4.wav vs transcript4.txt: 0.0599
|
| 22 |
+
WER for audio_sample_5.wav vs transcript5.txt: 0.1841
|
| 23 |
+
PASSED
|
| 24 |
+
|
| 25 |
+
====================================================================================== 1 passed in 87.08s (0:01:27) =======================================================================================
|