{"slug": "redact-pii-from-call-recordings-with-python-and-telnyx-ai", "title": "Redact PII from Call Recordings with Python and Telnyx AI", "summary": "Telnyx released a Python Flask example that redacts personally identifiable information (PII) from call transcripts and recordings using its AI inference API. The app replaces common PII types like names, credit card numbers, and SSNs with placeholders and returns structured JSON with a redaction map for audit trails. It supports both text and audio inputs, transcribing audio via the distil-whisper/distil-large-v2 model before redaction.", "body_md": "I put together a small Flask example that redacts PII from call transcripts and call recordings using Telnyx AI.\n\nCode:\n\n[https://github.com/team-telnyx/telnyx-code-examples/tree/main/call-recording-redactor-python](https://github.com/team-telnyx/telnyx-code-examples/tree/main/call-recording-redactor-python)\n\nThe app has two workflows:\n\nThe prompt asks the model to replace common PII with placeholders:\n\n`[NAME]`\n\n`[CREDIT_CARD]`\n\n`[SSN]`\n\n`[PHONE]`\n\n`[EMAIL]`\n\n`[ADDRESS]`\n\n`[DOB]`\n\n`[ACCOUNT_NUMBER]`\n\nThe useful part is that the response is structured JSON, not just rewritten text.\n\n```\n{\n  \"redacted_transcript\": \"Hi, this is [NAME] calling. My card number is [CREDIT_CARD].\",\n  \"redactions\": [\n    {\n      \"type\": \"name\",\n      \"original\": \"John Smith\",\n      \"redacted\": \"[NAME]\",\n      \"count\": 1\n    }\n  ],\n  \"items_redacted\": 2,\n  \"pii_types_found\": [\"name\", \"credit_card\"]\n}\n```\n\nThat means your app can show the sanitized transcript while still keeping an audit-friendly redaction map.\n\n```\ngit clone https://github.com/team-telnyx/telnyx-code-examples.git\ncd telnyx-code-examples/call-recording-redactor-python\ncp .env.example .env\npip install -r requirements.txt\npython app.py\n```\n\nConfigure `.env`\n\n:\n\n```\nTELNYX_API_KEY=your_telnyx_api_key\nAI_MODEL=meta-llama/Llama-3.3-70B-Instruct\nHOST=127.0.0.1\ncurl -X POST http://localhost:5000/redact \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"transcript\": \"Hi, this is John Smith calling. My card number is 4532-1234-5678-9012 and my SSN is 123-45-6789.\"\n  }'\n```\n\nThis calls Telnyx AI Inference through:\n\n```\nPOST /v2/ai/chat/completions\ncurl -X POST http://localhost:5000/redact/audio \\\n  -F \"file=@recording.wav\"\n```\n\nFor audio, the app first calls:\n\n```\nPOST /v2/ai/audio/transcriptions\n```\n\nusing:\n\n```\ndistil-whisper/distil-large-v2\n```\n\nThen it sends the transcript through the same PII redaction flow.\n\n`POST /redact`\n\n`POST /redact/audio`\n\n`GET /redactions`\n\n`GET /redactions/<id>`\n\n`GET /health`\n\nThis is a starter app, so it stores redaction jobs in memory.\n\nFor production, I would add:\n\nThe main pattern is reusable: turn communications data into structured, safer application data before it moves deeper into your systems.\n\nResources:", "url": "https://wpnews.pro/news/redact-pii-from-call-recordings-with-python-and-telnyx-ai", "canonical_source": "https://dev.to/sonam_50a41a4ced7e6b4f3fa/redact-pii-from-call-recordings-with-python-and-telnyx-ai-28pl", "published_at": "2026-07-29 19:24:41+00:00", "updated_at": "2026-07-29 20:35:58.954662+00:00", "lang": "en", "topics": ["artificial-intelligence", "developer-tools", "ai-products"], "entities": ["Telnyx", "Flask", "Python", "Llama-3.3-70B-Instruct", "distil-whisper/distil-large-v2"], "alternates": {"html": "https://wpnews.pro/news/redact-pii-from-call-recordings-with-python-and-telnyx-ai", "markdown": "https://wpnews.pro/news/redact-pii-from-call-recordings-with-python-and-telnyx-ai.md", "text": "https://wpnews.pro/news/redact-pii-from-call-recordings-with-python-and-telnyx-ai.txt", "jsonld": "https://wpnews.pro/news/redact-pii-from-call-recordings-with-python-and-telnyx-ai.jsonld"}}