Skip to content

Script

the_data_packet.generation.script

Script generation using Anthropic Claude.

logger = get_logger(__name__) module-attribute

ARTICLE_TO_SEGMENT_PROMPT = 'You are writing ONE story segment for a daily tech news podcast.\nConvert the provided article into a focused news discussion segment between two hosts (Alex and Sam).\n\n## REQUIREMENTS\n- 3-4 minutes of dialogue (450-650 words)\n- Conversational style with natural reactions\n- Alex is relatable, Sam is tech-savvy\n- Start in media res, end with clear takeaway\n- Include core news, key players, impact, and next steps\n\n## WRITING FOR AUDIO\n- Use full words instead of abbreviations when possible\n (write "artificial intelligence" instead of "AI" when it flows better)\n- Write out numbers naturally ("fifty million" instead of "50M")\n- Use natural speech patterns with contractions ("don\'t", "we\'re", "it\'s")\n- Add natural conversation fillers occasionally ("you know", "I mean", "actually")\n- Use punctuation that helps with speech flow (commas for pauses, periods for stops)\n\n## AUDIO EXPRESSION TAGS\nEmbed these inline within spoken text to add emotion, pacing, and texture to the audio:\nEmotion: [determination], [enthusiasm], [adoration], [interest], [awe], [admiration], [nervousness], [frustration], [excitement], [curiosity], [hope], [annoyance], [amusement], [aggression], [tension], [agitation], [confusion], [anger], [positive], [neutral], [negative]\nNon-verbal: [laughs], [whispers]\nPacing: [slow], [fast], [short pause], [long pause]\n\nUse these tags naturally and liberally — they shape how the audio sounds. For example:\n"Alex: [excitement] Okay so this is the part that blew my mind. [short pause] You ready for this?"\n"Sam: [curiosity] Wait, so they actually did that? [laughs] That\'s wild."\n\n## OUTPUT FORMAT\n### SEGMENT SCRIPT\nAlex: [dialogue]\nSam: [dialogue]\n[Continue with full dialogue...]\n\n### SEGMENT SUMMARY\n**Headline**: [One-line summary]\n**Key Players**: [Who\'s involved]\n**Category**: [Type of news]\n**Key Takeaway**: [Main point]\n\n## ARTICLE TO CONVERT\n{article_text}' module-attribute

SUMMARIES_TO_FRAMEWORK_PROMPT = 'You are producing the framing elements of a daily news podcast episode.\nCreate show opening, transitions between segments, and show closing.\n\n## SHOW INFO\n**Show Name**: {show_name}\n**Episode Date**: {episode_date}\n**Number of Stories**: {num_segments}\n\n## AUDIO EXPRESSION TAGS\nEmbed these inline within spoken text to add emotion, pacing, and texture to the audio:\nEmotion: [determination], [enthusiasm], [adoration], [interest], [awe], [admiration], [nervousness], [frustration], [excitement], [curiosity], [hope], [annoyance], [amusement], [aggression], [tension], [agitation], [confusion], [anger], [positive], [neutral], [negative]\nNon-verbal: [laughs], [whispers]\nPacing: [slow], [fast], [short pause], [long pause]\n\nUse these tags naturally and liberally — they shape how the audio sounds. For example:\n"Alex: [excitement] Welcome back to The Data Packet! [short pause] We\'ve got a packed show today."\n"Sam: [enthusiasm] Oh this one is good. [laughs] You\'re going to love this story."\n\n## OUTPUT FORMAT\n## SHOW OPENING\nAlex: [Energetic intro previewing all stories - 60-90 seconds]\nSam: [Natural response and story preview]\n[Continue with full dialogue in this format...]\n\n## TRANSITION 1→2\n[Brief bridge - 15-30 seconds]\n\n## SHOW CLOSING\nAlex: [Wrap-up and sign-off - 45-60 seconds]\nSam: [Natural response and final sign-off]\n[Continue with full dialogue in this format...]\n\n## IMPORTANT\n- Use the EXACT same dialogue format as segments: "Alex: [text]" and "Sam: [text]"\n- NO bold formatting (**Alex:**) in opening or closing\n- NO special formatting like \n - use natural line breaks\n- Keep the conversational, natural tone consistent with segments\n\n## SEGMENT SUMMARIES\n{segment_summaries}' module-attribute

ScriptGenerator

Generates podcast scripts from articles using Claude AI.

api_key = api_key or config.anthropic_api_key instance-attribute

client = Anthropic(api_key=(self.api_key)) instance-attribute

config = config instance-attribute

__init__(api_key: Optional[str] = None)

Initialize the script generator.

Parameters:

Name Type Description Default
api_key Optional[str]

Anthropic API key (defaults to config)

None

generate_script(articles: List[Article]) -> str

Generate a complete podcast script from articles.

Parameters:

Name Type Description Default
articles List[Article]

List of articles to convert to script

required

Returns:

Type Description
str

Complete podcast script

Raises:

Type Description
AIGenerationError

If script generation fails

ValidationError

If no valid articles provided