"feat:enhance-podcast-topic-ai"
This commit is contained in:
@@ -22,30 +22,45 @@ class PodcastBibleService:
|
||||
logger.info(f"Generating Podcast Bible for user {user_id}")
|
||||
|
||||
try:
|
||||
preferences = self.personalization_service.get_user_preferences(user_id)
|
||||
preferences = self.personalization_service.get_user_preferences(user_id) or {}
|
||||
if not isinstance(preferences, dict):
|
||||
logger.warning(f"Podcast Bible preferences payload is non-dict for user {user_id}, using defaults")
|
||||
preferences = {}
|
||||
|
||||
writing_style = preferences.get("writing_style", {})
|
||||
if not isinstance(writing_style, dict):
|
||||
writing_style = {}
|
||||
|
||||
style_prefs = preferences.get("style_preferences", {})
|
||||
if not isinstance(style_prefs, dict):
|
||||
style_prefs = {}
|
||||
|
||||
target_audience = preferences.get("target_audience", {})
|
||||
if not isinstance(target_audience, dict):
|
||||
target_audience = {}
|
||||
|
||||
industry = preferences.get("industry", "General Business")
|
||||
if not isinstance(industry, str) or not industry.strip():
|
||||
industry = "General Business"
|
||||
|
||||
# 1. Map Host Persona
|
||||
host = HostPersona(
|
||||
name="Your AI Host",
|
||||
background=f"Expert in {industry}",
|
||||
expertise_level=writing_style.get("complexity", "Expert").capitalize(),
|
||||
expertise_level=str(writing_style.get("complexity") or "Expert").capitalize(),
|
||||
personality_traits=[
|
||||
writing_style.get("tone", "Professional").capitalize(),
|
||||
writing_style.get("engagement_level", "Informative").capitalize()
|
||||
str(writing_style.get("tone") or "Professional").capitalize(),
|
||||
str(writing_style.get("engagement_level") or "Informative").capitalize()
|
||||
],
|
||||
vocal_style=writing_style.get("voice", "Authoritative").capitalize(),
|
||||
vocal_characteristics=["Clear", "Articulate", writing_style.get("voice", "Steady")],
|
||||
vocal_style=str(writing_style.get("voice") or "Authoritative").capitalize(),
|
||||
vocal_characteristics=["Clear", "Articulate", str(writing_style.get("voice") or "Steady")],
|
||||
look=f"A professional individual dressed in business-casual attire, fitting the {industry} industry aesthetic.",
|
||||
catchphrases=[]
|
||||
)
|
||||
|
||||
# 2. Map Audience DNA
|
||||
audience = AudienceDNA(
|
||||
expertise_level=target_audience.get("expertise_level", "Intermediate").capitalize(),
|
||||
expertise_level=str(target_audience.get("expertise_level") or "Intermediate").capitalize(),
|
||||
interests=target_audience.get("interests", ["Industry Trends", "Innovation"]),
|
||||
pain_points=target_audience.get("pain_points", ["Staying ahead of competition", "Efficiency"]),
|
||||
demographics=None
|
||||
@@ -54,15 +69,15 @@ class PodcastBibleService:
|
||||
# 3. Map Brand DNA
|
||||
brand = BrandDNA(
|
||||
industry=industry,
|
||||
tone=writing_style.get("tone", "Professional").capitalize(),
|
||||
communication_style=writing_style.get("engagement_level", "Informative").capitalize(),
|
||||
tone=str(writing_style.get("tone") or "Professional").capitalize(),
|
||||
communication_style=str(writing_style.get("engagement_level") or "Informative").capitalize(),
|
||||
key_messages=preferences.get("brand_values", []),
|
||||
competitor_context=None
|
||||
)
|
||||
|
||||
# 4. Map Visual Style
|
||||
visual = VisualStyle(
|
||||
style_preset=style_prefs.get("aesthetic", "Professional Studio").capitalize(),
|
||||
style_preset=str(style_prefs.get("aesthetic") or "Professional Studio").capitalize(),
|
||||
environment=f"A modern {industry}-themed podcast studio with professional equipment.",
|
||||
lighting="Soft, warm studio lighting with subtle rim lights.",
|
||||
color_palette=preferences.get("brand_colors", ["#1e293b", "#3b82f6"]),
|
||||
@@ -72,7 +87,7 @@ class PodcastBibleService:
|
||||
# 5. Map Audio Environment
|
||||
audio_env = AudioEnvironment(
|
||||
soundscape="Pristine studio environment with deep, warm acoustics.",
|
||||
music_mood=f"{writing_style.get('tone', 'Professional').capitalize()} & {writing_style.get('engagement_level', 'Upbeat').capitalize()}",
|
||||
music_mood=f"{str(writing_style.get('tone') or 'Professional').capitalize()} & {str(writing_style.get('engagement_level') or 'Upbeat').capitalize()}",
|
||||
sfx_style="Modern, clean interface-inspired sounds."
|
||||
)
|
||||
|
||||
@@ -80,11 +95,11 @@ class PodcastBibleService:
|
||||
show_rules = ShowRules(
|
||||
intro_format=f"Start with a high-energy hook about the episode topic, followed by a warm welcome and an overview of the {industry} insights to be shared.",
|
||||
outro_format="Summarize the key takeaways, provide a clear call to action, and sign off with a professional closing.",
|
||||
interaction_tone=writing_style.get("engagement_level", "Conversational").capitalize(),
|
||||
interaction_tone=str(writing_style.get("engagement_level") or "Conversational").capitalize(),
|
||||
constraints=[
|
||||
"Avoid overly technical jargon unless defined",
|
||||
"Keep segments concise and factual",
|
||||
f"Maintain a {writing_style.get('tone', 'Professional')} tone at all times"
|
||||
f"Maintain a {str(writing_style.get('tone') or 'Professional')} tone at all times"
|
||||
]
|
||||
)
|
||||
|
||||
@@ -102,7 +117,7 @@ class PodcastBibleService:
|
||||
return bible
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error generating Podcast Bible: {str(e)}")
|
||||
logger.error(f"Error generating Podcast Bible: {str(e)}", exc_info=True)
|
||||
# Return a default bible if something goes wrong to ensure project creation doesn't fail
|
||||
return self._get_default_bible(project_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user