Spaces:
Runtime error
Runtime error
File size: 5,714 Bytes
a62077e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# Transcript Debugging Guide
## Issue: Empty Transcripts ("No transcript available")
## Complete Flow Analysis
### 1. Django App → API Request (`slaq-version-c/diagnosis/ai_engine/detect_stuttering.py`)
**Location:** Line 269-274
```python
response = requests.post(
self.api_url,
files=files,
data={
"transcript": proper_transcript if proper_transcript else "",
"language": lang_code,
},
timeout=self.api_timeout
)
```
**Status:** ✅ Sending transcript parameter correctly
---
### 2. API Receives Request (`slaq-version-c-ai-enginee/app.py`)
**Location:** Line 70-73
```python
@app.post("/analyze")
async def analyze_audio(
audio: UploadFile = File(...),
transcript: str = Form("") # ✅ Fixed: Now uses Form() for multipart
):
```
**Status:** ✅ Fixed - Now correctly receives transcript via Form()
---
### 3. API Calls Model (`slaq-version-c-ai-enginee/app.py`)
**Location:** Line 106
```python
result = detector.analyze_audio(temp_file, transcript)
```
**Status:** ✅ Passing transcript correctly
---
### 4. Model Transcribes Audio (`slaq-version-c-ai-enginee/diagnosis/ai_engine/detect_stuttering.py`)
**Location:** Line 313-369 (`_transcribe_with_timestamps`)
**Potential Issues:**
- ❓ IndicWav2Vec decoding might not work with `processor.batch_decode()`
- ❓ Need to use tokenizer directly
- ❓ Model might not be producing valid predictions
**Status:** ⚠️ **LIKELY ISSUE HERE** - Decoding method may be incorrect
---
### 5. Model Returns Result (`slaq-version-c-ai-enginee/diagnosis/ai_engine/detect_stuttering.py`)
**Location:** Line 787-794
```python
actual_transcript = transcript if transcript else ""
target_transcript = proper_transcript if proper_transcript else transcript if transcript else ""
return {
'actual_transcript': actual_transcript,
'target_transcript': target_transcript,
...
}
```
**Status:** ✅ Returns transcripts correctly (if transcript is not empty)
---
### 6. API Returns Response (`slaq-version-c-ai-enginee/app.py`)
**Location:** Line 109-113
```python
actual = result.get('actual_transcript', '')
target = result.get('target_transcript', '')
logger.info(f"📝 Result transcripts - Actual: '{actual[:100]}' (len: {len(actual)}), Target: '{target[:100]}' (len: {len(target)})")
return result
```
**Status:** ✅ Returns JSON with transcripts
---
### 7. Django Receives Response (`slaq-version-c/diagnosis/ai_engine/detect_stuttering.py`)
**Location:** Line 279-410
```python
result = response.json()
# ... formatting ...
actual_transcript = str(api_result.get('actual_transcript', '')).strip()
target_transcript = str(api_result.get('target_transcript', '')).strip()
```
**Status:** ✅ Extracts transcripts correctly
---
### 8. Django Saves to Database (`slaq-version-c/diagnosis/tasks.py`)
**Location:** Line 141-142
```python
actual_transcript=actual_transcript,
target_transcript=target_transcript,
```
**Status:** ✅ Saves correctly
---
## Root Cause Analysis
### Most Likely Issue: Transcription Decoding
The IndicWav2Vec model (`ai4bharat/indicwav2vec-hindi`) may require:
1. **Direct tokenizer access** instead of `processor.batch_decode()`
2. **CTC decoding** with proper tokenizer
3. **Special handling** for Indic scripts
### Fix Applied
Updated `_transcribe_with_timestamps()` to:
1. Try multiple decoding methods
2. Use tokenizer directly if available
3. Add comprehensive error logging
4. Log predicted IDs for debugging
---
## Debugging Steps
### 1. Check API Logs
When processing audio, look for:
```
📝 Transcribed text: '...' (length: X)
📝 Final return - Actual: '...' (len: X), Target: '...' (len: Y)
📝 Result transcripts - Actual: '...' (len: X), Target: '...' (len: Y)
```
### 2. Check Django Logs
Look for:
```
📝 Final transcripts - Actual: X chars, Target: Y chars
📝 Saving transcripts - Actual: X chars, Target: Y chars
```
### 3. Check Database
Query the `AnalysisResult` table:
```sql
SELECT actual_transcript, target_transcript, LENGTH(actual_transcript) as actual_len, LENGTH(target_transcript) as target_len
FROM diagnosis_analysisresult
ORDER BY created_at DESC LIMIT 5;
```
### 4. Test API Directly
```bash
curl -X POST "http://localhost:7860/analyze" \
-F "audio=@test.wav" \
-F "transcript=test transcript" \
-F "language=hin"
```
Check the response JSON for `actual_transcript` and `target_transcript`.
---
## Next Steps
1. **Rebuild Docker image** with latest changes
2. **Check logs** during audio processing
3. **Verify processor structure** - logs will show processor attributes
4. **Test with Hindi audio** - model is optimized for Hindi
5. **Check if model is loaded correctly** - verify HF_TOKEN is working
---
## Expected Log Output (Success)
```
🚀 Initializing Advanced AI Engine on cpu...
✅ HF_TOKEN found - using authenticated model access
📋 Processor type: <class 'transformers.models.wav2vec2.processing_wav2vec2.Wav2Vec2Processor'>
📋 Processor attributes: ['batch_decode', 'decode', 'feature_extractor', 'tokenizer', ...]
📋 Tokenizer type: <class 'transformers.models.wav2vec2.tokenization_wav2vec2.Wav2Vec2CTCTokenizer'>
📝 Transcribed text: 'नमस्ते मैं हिंदी बोल रहा हूं' (length: 25)
📝 Final return - Actual: 'नमस्ते मैं हिंदी बोल रहा हूं' (len: 25), Target: '...' (len: X)
```
---
## If Still Empty
1. **Model may not be loaded correctly** - check HF_TOKEN
2. **Audio format issue** - ensure 16kHz mono WAV
3. **Model not producing predictions** - check predicted_ids in logs
4. **Tokenizer mismatch** - IndicWav2Vec may need special tokenizer initialization
|