AI_USAGE_GUIDE_FINAL.md•6.55 kB
# SRT Translation MCP Server - AI Usage Guide
## 🚨 CRITICAL FOR AI SYSTEMS 🚨
The `detect_conversations` function has been **COMPLETELY REDESIGNED** to return **METADATA ONLY** - **NO ACTUAL TEXT CONTENT**.
## ❌ WHAT IT DOES NOT RETURN
- ❌ Actual subtitle text content
- ❌ Full conversation text
- ❌ Any readable text for translation
- ❌ Translated text content
- ❌ Source text content
- ❌ Any actual subtitle text
## ✅ WHAT IT DOES RETURN
- ✅ Chunk boundaries and timing information
- ✅ Language detection (Arabic vs English)
- ✅ Content complexity assessment
- ✅ Translation priority ranking
- ✅ Topic keywords (first 3 words only)
- ✅ Speaker information
- ✅ Content type classification
## 🤖 AI TRANSLATION WORKFLOW
### Step 1: Analyze File Structure (METADATA ONLY)
```javascript
// Call detect_conversations first - RETURNS METADATA ONLY!
const metadata = await mcp_call('detect_conversations', {
content: srtFileContent
});
// ⚠️ This returns metadata only - NO actual text content!
```
### Step 2: Review Metadata for Planning
```javascript
const analysis = JSON.parse(metadata.content[0].text);
// Check language distribution
console.log(analysis.languageDistribution); // {ar: 59, en: 0}
// Review chunk priorities
analysis.chunks.forEach(chunk => {
console.log(`Chunk ${chunk.id}: ${chunk.translationPriority} priority, ${chunk.complexity} complexity`);
});
```
### Step 3: Plan Translation Strategy
```javascript
// Prioritize high-priority chunks
const highPriorityChunks = analysis.chunks.filter(c => c.translationPriority === 'high');
// Check language detection
const arabicChunks = analysis.chunks.filter(c => c.languageInfo.primary === 'ar');
```
### Step 4: Execute Translation (ACTUAL TEXT CONTENT)
```javascript
// Use translate_srt for full file translation - THIS RETURNS ACTUAL TRANSLATED TEXT!
const translated = await mcp_call('translate_srt', {
content: srtFileContent,
targetLanguage: 'en',
sourceLanguage: 'ar' // Based on metadata analysis
});
// ✅ This returns the complete translated SRT file with actual text content!
// OR use AI workflow for intelligent translation:
const aiTranslated = await mcp_call('translate_with_ai_workflow', {
content: srtFileContent,
targetLanguage: 'en',
sourceLanguage: 'ar',
aiWorkflow: workflowConfig
});
// ✅ This also returns actual translated text with AI workflow!
```
## 📊 METADATA STRUCTURE EXPLAINED
### File-Level Metadata
```json
{
"chunkCount": 59, // Total chunks to process
"totalDuration": 7525000, // Duration in milliseconds
"languageDistribution": {"ar": 59}, // Language counts
"speakerDistribution": {"unknown": 59}, // Speaker counts
"chunks": [...] // Individual chunk data
}
```
### Chunk-Level Metadata
```json
{
"id": "chunk-0", // Unique identifier
"startTime": "0:0:2", // Start timestamp
"endTime": "0:0:13", // End timestamp
"duration": 11000, // Duration in milliseconds
"subtitleCount": 2, // Number of subtitles
"speaker": null, // Speaker name (if detected)
"languageInfo": { // Language detection
"primary": "ar", // Primary language
"confidence": 0.8, // Detection confidence
"indicators": ["arabic_script"] // Detection indicators
},
"contentType": "general", // dialogue/narration/question/general
"complexity": "medium", // low/medium/high
"translationPriority": "low", // low/medium/high
"topicKeywords": ["hello", "this"] // First 3 words only
}
```
## 🎯 AI DECISION MAKING GUIDE
### Language Detection
- Use `languageInfo.primary` to determine source language
- Use `languageInfo.confidence` to assess reliability
- Arabic: `"ar"`, English: `"en"`
### Translation Planning
- **High Priority**: Dialogue and questions (translate first)
- **Medium Priority**: Complex chunks (need more attention)
- **Low Priority**: Simple narration (translate last)
### Complexity Assessment
- **Low**: Simple chunks (< 5 subtitles, < 10 seconds)
- **Medium**: Moderate chunks (5-10 subtitles, 10-30 seconds)
- **High**: Complex chunks (> 10 subtitles, > 30 seconds)
### Content Type Handling
- **Dialogue**: Maintain speaker identity and conversational tone
- **Narration**: Use formal language style
- **Questions**: Preserve question structure and intonation
- **General**: Standard translation approach
## ⚠️ COMMON AI MISTAKES TO AVOID
1. **DON'T** try to extract text from metadata - use `translate_srt()` instead
2. **DON'T** use `topicKeywords` for translation - they're for context only
3. **DON'T** ignore `translationPriority` - it helps optimize translation order
4. **DON'T** skip language detection - use `languageInfo.primary` for source language
5. **DON'T** expect translated text from `detect_conversations()` - it's metadata only!
6. **DON'T** ask for "actual Arabic translation" from metadata functions
7. **DO** use `translate_srt()` or `translate_with_ai_workflow()` for actual translation
## 🎯 WHICH FUNCTION TO USE FOR WHAT
### For Planning and Analysis (METADATA ONLY):
- ✅ `detect_conversations()` - Returns metadata for AI decision-making
- ✅ `analyze_content_for_ai()` - Returns content analysis
- ✅ `generate_ai_workflow()` - Returns workflow configuration
### For Actual Translation (TEXT CONTENT):
- ✅ `translate_srt()` - Returns complete translated SRT file
- ✅ `translate_with_ai_workflow()` - Returns translated SRT with AI workflow
- ✅ `translate_chunk()` - Returns translated chunk data
## 🔄 RECOMMENDED AI WORKFLOW
1. **Analyze**: Call `detect_conversations()` to get metadata
2. **Plan**: Review metadata to understand file structure
3. **Prioritize**: Focus on high-priority chunks first
4. **Translate**: Use `translate_srt()` for actual translation
5. **Validate**: Check results against original metadata expectations
## 📈 BENEFITS FOR AI
- **Efficiency**: No need to process full text for analysis
- **Intelligence**: Informed translation decisions based on metadata
- **Scalability**: Works with large files without overwhelming AI
- **Quality**: Better translation results through structured planning
---
**Remember**: The `detect_conversations` function is your **planning tool**, not your **translation tool**. Use it to understand the file structure, then use `translate_srt()` for actual translation work.