Back to Prompt Library
implementation

Implement Deepgram Audio Transcription Tool

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: Real-Time AI Content Compliance Monitor

Format
Code-aware
Lines
15
Sections
4
Linked challenge
Real-Time AI Content Compliance Monitor

Prompt source

Original prompt text with formatting preserved for inspection.

15 lines
4 sections
No variables
1 code block
Implement a Python function `transcribe_audio(audio_file_path: str) -> str` that simulates using Deepgram to transcribe an audio file into text. This function should include error handling and return the transcribed text. This will be registered as a tool for your 'Content Ingestor/Analyzer Agent'. Provide the code snippet.

```python
import os
from typing import Dict, Any

# Simulate Deepgram transcription. In a real scenario, you'd use Deepgram SDK.
def transcribe_audio_mock(audio_file_path: str) -> Dict[str, Any]:
    # This is a mock implementation. Replace with actual Deepgram API call.
    if "deepfake_audio.mp3" in audio_file_path:
        return {"transcript": "Just saw a deepfake of the President. It was so convincing, you wouldn't believe it's AI-generated!"}
    elif "normal_audio.mp3" in audio_file_path:
        return {"transcript": "This is a regular news update."}    
    return {"transcript": ""}

# To be used in Claude Agent SDK:
# agent_builder.tool(tool_name="transcribe_audio", description="Transcribes audio content to text.")(transcribe_audio_mock)
```

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Hold the task contract and output shape stable so generated implementations remain comparable.

Tune next

Update libraries, interfaces, and environment assumptions to match the stack you actually run.

Verify after

Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.