
    5i                    H    d Z ddlmZ ddlmZmZmZmZ ddZ G d d      Z	y)	u   
Timeline Planner Agent – calculates exact timestamps and cut points.

This agent is DETERMINISTIC: it does not call the LLM. Timing is derived
from word count in the narration text, which gives reproducible results
and avoids unnecessary API costs.
    )annotations)AllSceneTTSPipelineConfigSceneTimelineTimelinec                @    t        |       dz  }| |dz  z
  }|dd|dS )zFormat seconds as MM:SS.<   02d:z05.2f)int)secondsminutessecss      @/root/.openclaw/workspace/visionaryfx/agents/timeline_planner.py_format_timer      s3    'lb GWr\!Dc]!D<((    c                       e Zd ZdZddZddZy)TimelinePlannerAgentz4Calculates the production timeline from TTS scripts.c                j    |j                   | _        |j                  | _        |j                  | _        y )N)speaking_rate_wpswpsmin_scene_durationmin_durationtransition_duration
transition)selfconfigs     r   __init__zTimelinePlannerAgent.__init__   s*    ++"55 44r   c                   d}g }|j                   D ]  }t        |j                  j                               }|| j                  z  }t        || j                        dz   }|}||z   }	|	}
|j                  t        |j                  t        |      t        |	      t        |d      t        |
      |j                  t        |j                         k  rdnd             |	} |}t        t        |d      t        |      |      S )Ng        g      ?   zcrossfade 0.3szfade to black 0.5s)scene_number
time_starttime_endduration_seconds	cut_pointr   )total_duration_secondstotal_duration_formattedscenes)r(   lentts_textsplitr   maxr   appendr   r!   r   roundr   )r   ttscurrent_timescene_timelines	scene_tts
word_countnarration_durationscene_durationr"   r#   r%   totals               r   planzTimelinePlannerAgent.plan"   s   /1 	$IY//5578J!+dhh!6 !3T5F5FG#MN%J#n4H I""!*!7!7+J7)(3%*>1%=*95 %11C

OC )1 $L1	$4 #(?%1%%8"
 	
r   N)r   r   )r/   r   returnr   )__name__
__module____qualname____doc__r   r7    r   r   r   r      s    >5
#
r   r   N)r   floatr8   str)
r<   
__future__r   modelsr   r   r   r   r   r   r=   r   r   <module>rB      s(    # )+
 +
r   