Skip to content

Feedback: guides-real_time_lemur

Original URL: https://www.assemblyai.com/docs/guides/real_time_lemur
Category: guides
Generated: 05/08/2025, 4:38:54 pm


Generated: 05/08/2025, 4:38:53 pm

Technical Documentation Analysis: Real-time LeMUR Integration

Section titled “Technical Documentation Analysis: Real-time LeMUR Integration”

This documentation provides a functional code example but suffers from poor structure, missing context, and several user experience issues that could lead to confusion and implementation problems.

Problem: Users don’t know what to install before running the code.

Solution: Add a clear prerequisites section:

## Prerequisites
### Required Dependencies
```bash
pip install pyaudio websocket-client requests
  • Python 3.7+
  • Microphone access
  • Internet connection
  • AssemblyAI API key (get one here)
  • macOS: May require brew install portaudio
  • Ubuntu/Debian: May require sudo apt-get install python3-pyaudio
  • Windows: PyAudio installation may require Visual Studio Build Tools
### 2. **Poor Document Structure & Missing Context**
**Problem**: The introduction is confusing and doesn't explain what LeMUR is or why you'd use this integration.
**Solution**: Restructure with proper introduction:
```markdown
# Real-time Speech Analysis with LeMUR
## Overview
This guide shows how to combine AssemblyAI's real-time Speech-to-Text with LeMUR (Large Language Model Universal Router) to analyze conversations as they happen. This integration allows you to:
- Transcribe speech in real-time
- Automatically analyze conversation content when the session ends
- Get AI-powered insights and feedback on the conversation
## What is LeMUR?
LeMUR is AssemblyAI's AI analysis platform that can summarize, analyze, and extract insights from transcribed text using advanced language models.
## Use Cases
- Meeting analysis and feedback
- Interview coaching and evaluation
- Call center quality assurance
- Educational assessment

Problem: References to WAV recording functionality that isn’t implemented, misleading comments.

Solution: Clean up the code and comments:

# Remove these unused variables:
# recorded_frames = []
# recording_lock = threading.Lock()
# Fix misleading comments:
# Remove: "Audio will be saved to a WAV file when the session ends."
# Add better function documentation:
def analyze_with_lemur(text):
"""
Analyzes conversation transcript using LeMUR.
Args:
text (str): The complete conversation transcript
Returns:
str: LeMUR analysis response
Raises:
requests.RequestException: If API call fails
"""

Problem: No guidance on common errors or API failures.

Solution: Add comprehensive error handling section:

## Error Handling & Troubleshooting
### Common Issues
| Error | Cause | Solution |
|-------|-------|----------|
| `ModuleNotFoundError: pyaudio` | Missing dependency | Install with `pip install pyaudio` |
| `401 Unauthorized` | Invalid API key | Check your API key in the dashboard |
| `Device not found` | No microphone detected | Ensure microphone is connected and permissions granted |
| `Connection refused` | Network/firewall issue | Check internet connection and firewall settings |
### Adding Error Handling
```python
def analyze_with_lemur(text):
try:
result = requests.post("https://api.assemblyai.com/lemur/v3/generate/task",
headers=headers, json=lemur_data, timeout=30)
result.raise_for_status() # Raises exception for HTTP errors
return result.json()["response"]
except requests.exceptions.RequestException as e:
print(f"LeMUR API error: {e}")
return "Analysis failed - please try again"
except KeyError:
print("Unexpected response format from LeMUR API")
return "Analysis failed - unexpected response format"

Problem: Limited explanation of configuration options and LeMUR parameters.

Solution: Add detailed configuration section:

## Configuration Options
### Audio Settings
```python
CONNECTION_PARAMS = {
"sample_rate": 16000, # Audio sample rate (8000, 16000, 44100)
"format_turns": True, # Enable speaker turn detection
"word_boost": ["technical", "specific", "terms"], # Boost specific words
"language_code": "en_us", # Language code (optional)
}
lemur_data = {
"prompt": "Custom analysis prompt here...",
"input_text": text,
"final_model": "anthropic/claude-sonnet-4-20250514", # Available models
"max_output_size": 3000, # Maximum response length
"temperature": 0.7, # Creativity level (0.0-1.0)
}
  • anthropic/claude-sonnet-4-20250514 - Balanced performance
  • anthropic/claude-haiku-4-20250308 - Faster responses
  • default - AssemblyAI’s optimized model
### 6. **Missing Examples & Use Cases**
**Problem**: Only one generic coaching example provided.
**Solution**: Add multiple practical examples:
```markdown
## Example Prompts for Different Use Cases
### Meeting Summary
```python
prompt = """
Summarize this meeting transcript with:
1. Key decisions made
2. Action items and owners
3. Topics that need follow-up
4. Overall meeting effectiveness
"""
prompt = """
Analyze this sales conversation for:
1. Customer pain points mentioned
2. Objections raised and how they were handled
3. Next steps discussed
4. Sales techniques used
5. Opportunities for improvement
"""
prompt = """
Evaluate this interview transcript:
1. Candidate's key strengths demonstrated
2. Areas where answers could be improved
3. Communication style assessment
4. Technical competency shown
5. Cultural fit indicators
"""

Problem: No guidance on testing the setup or validating results.

Solution: Add testing section:

## Testing Your Setup
### Quick Test
1. Run the script with a short test phrase: "Hello, this is a test"
2. Press Ctrl+C after speaking
3. Verify you see both transcript and LeMUR analysis
### Expected Output

WebSocket connection opened. Connected to: wss://streaming.assemblyai.com/v3/ws… Session began: ID=…, ExpiresAt=… Hello, this is a test. Ctrl+C received. Stopping… Session Terminated: Audio Duration=3.2s, Session Duration=5.1s Analyzing conversation with LeMUR… [LeMUR analysis output here]

### Validation Checklist
- [ ] Microphone input is working
- [ ] Real-time transcription appears
- [ ] Session terminates cleanly
- [ ] LeMUR analysis is generated
- [ ] No error messages appear
  1. Add prerequisites and installation instructions
  2. Restructure with proper introduction and context
  3. Clean up code comments and remove dead code
  4. Add comprehensive error handling examples
  5. Expand configuration documentation
  6. Provide multiple use-case examples
  7. Include testing and validation guidance
  8. Add troubleshooting section
  9. Improve code organization and documentation
  10. Add links to related documentation

These improvements would transform this from a basic code dump into a comprehensive, user-friendly guide that developers can confidently follow and customize for their needs.