/ core / attention / __pycache__ / podcast_pipeline.cpython-314.pyc
podcast_pipeline.cpython-314.pyc
  1  +
  2  �gif6�
  3  ���Rt^RIHuHt^RIHtHt^RIHtH	t	^RI
  4  HtHtH
t
HtHt^RIHt^RIt^RIt]!RR44t]!RR	44t!R
  5  R4t!RR
4t]R8XEdu^RIt]!R4]P6P9R4t]P6P=]4'g]!R]24]!^4]!]4t ] PC4t"]!R]#!]"4R24] PI^^
  6  R7t%]!R4]%F_t&]&PN'd]&PNPQR4MRt)]!R])R]&PTR]&PVR,R24Ka	] PY4t-]!R]#!]-4R24]-R,F6t&]&P\^<,t/]!R ]&PVR!,R"]/R#24K8	]!R$4R#R#)%a�
  7  Podcast Resonance Training Pipeline
  8  
  9  Full pipeline from attention capture to cognitive fingerprint training:
 10  
 11  1. CAPTURE - Pull Overcast OPML, extract recently played episodes
 12  2. TRANSCRIBE - Get or fetch transcript (Podwise, Whisper, etc.)
 13  3. PREDICT - Analyze content, predict resonance based on cognitive fingerprint
 14  4. PRESENT - Output prediction to Obsidian note for operator review
 15  5. REVEAL - Operator reorders and annotates with commentary
 16  6. TRAIN - Compare predictions to actuals, update cognitive fingerprint
 17  
 18  This pipeline anchors around ATTENTION - what you chose to listen to
 19  is already a signal of resonance. What you highlight afterward is
 20  deeper resonance.
 21  N)�	dataclass�field)�datetime�	timedelta)�Optional�List�Dict�Any�Tuple)�Pathc�Ha�]tRt^toRtRtRtRt^tRt	Rt
 22  V3RltRtVt
R#)�PodcastEpisodez A podcast episode from Overcast.NFc��<�V^8�dQh/S[;R&S[;R&S[;R&S[S[,;R&S[S[,;R&S[;R&S[;R&S[S[,;R&S[S[,;R	&#)
 23  ��overcast_id�title�podcast_name�pub_date�user_updated_date�played�progress_seconds�overcast_url�
enclosure_url)�strrr�bool�int)�format�
__classdict__s"��B/Users/rcerf/repos/Sovereign_OS/core/attention/podcast_pipeline.py�__annotate__�PodcastEpisode.__annotate__s���������J�	�
 24  ����x� �'�
� ��)�0��
�������3�-�&���C�=�'���)�__name__�
 25  __module__�__qualname__�__firstlineno__�__doc__rrrrrr�__annotate_func__�__static_attributes__�__classdictcell__�rs@rr
r
s1����*�$(�H�,0���F���"&�L�#'�M��r!r
c�<a�]tRt^)toRtRtRtRtV3RltRt	Vt
 26  R#)�ListeningSessionz!A listening session for training.NFc�v<�V^8�dQh/S[;R&S[;R&S[S[,;R&S[S[,;R&S[;R&#)r�episode�listened_at�transcript_path�prediction_path�training_complete)r
rrrr)rrs"�rr�ListeningSession.__annotate__)sN���������	�
 27  �c�]�)���c�]�)�
��#�r!r")r#r$r%r&r'r1r2r3r(r)r*r+s@rr-r-)s!����+�&*�O�%)�O�#���r!r-c�a�]tRt^3toRtV3RlRltV3RlRltV3RlRltRV3RlR	lltV3R
 28  lRlt	Rt
 29  VtR
#)�OvercastParserz;
 30  Parses Overcast OPML export to extract listening history.
 31  c� <�V^8�dQhRS[/#)r�	opml_path)r)rrs"�rr�OvercastParser.__annotate__8s���	1�	1�#�	1r!c�B�\V4Vn/Vn.VnR#)z^
 32  Initialize parser with path to OPML file.
 33  
 34  Args:
 35      opml_path: Path to overcast.opml export
 36  N)rr8�podcasts�episodes)�selfr8s&&r�__init__�OvercastParser.__init__8s���i����(*��
�.0��
r!c�0<�V^8�dQhRS[S[,/#�r�return�rr
)rrs"�rrr9Cs�����t�N�+�r!c�^�\P!VP4pVP4pVP	R4pVf.#VPR4F�pVP
RR4pVR8XgKVP
RR4pVP
RVP
RR	44pWpPV&VPR4FQpVP
R4R
 37  8XgKVPW�4p	V	'gK6VPPV	4KS	K�	VP#)z\
 38  Parse the OPML file and extract all episodes.
 39  
 40  Returns:
 41      List of PodcastEpisode objects
 42  �body�outline�type��rss�
 43  overcastIdr�text�Unknownzpodcast-episode)�ET�parser8�getroot�find�iter�getr;�findall�_parse_episoder<�append)
 44  r=�tree�rootrErF�outline_type�
 45  podcast_idr�episode_outliner/s
 46  &         rrN�OvercastParser.parseCs����x�x����'���|�|�~���y�y�� ���<��I��y�y��+�G�"�;�;�v�r�2�L��u�$�$�[�[��r�:�
 47  �&�{�{�7�G�K�K��	�4R�S��,8�
�
�j�)�(/���y�'A�O�&�*�*�6�2�6G�G�"&�"5�"5�o�"T��"�7� �M�M�0�0��9�	(B�,� �}�}�r!c�P<�V^8�dQhRS[PRS[RS[S[,/#)rrFrrB)rM�Elementrrr
)rrs"�rrr9ds2���2�2����2��2�
 48  �.�	!�	2r!c
���\P!VPRR44pRpRpVPR4pV'd(\P!VPRR44pVPR4pV'd(\P!VPRR44p^pVPRR	4p	V	'd
\
V	4p\VPR
 49  R4VVVVVPR4R
8HVVPR4VPR4R7	# L�;i L�;i Lf;i \dp
 50  \RT
 51  24Rp
 52  ?
 53  R#Rp
 54  ?
 55  ii;i)z'Parse a single episode outline element.rrLN�pubDate�Zz+00:00�userUpdatedDate�progress�0rJrHr�1�overcastUrl�enclosureUrl)	rrrrrrrrrzError parsing episode: )
 56  �html�unescaperRr�
fromisoformat�replacerr
�	Exception�print)r=rFrrr�user_updated�pub_date_str�user_updated_strrb�progress_str�es&&&        rrT�OvercastParser._parse_episodedsX��,	��M�M�'�+�+�g�y�"A�B�E��H��L�"�;�;�y�1�L���'�5�5�l�6J�6J�3�PX�6Y�Z�H� '�{�{�+<�=����#+�#9�#9�:J�:R�:R�SV�X`�:a�#b�L�
 57  �H�"�;�;�z�3�7�L���"�<�0�H�"�#�K�K��b�9��)�!�".��{�{�8�,��3�!)�$�[�[��7�%�k�k�.�9�
 58  �
 59  
��'����������	��+�A�3�/�0���	�sa�AD=�&D(�,D=�&D/�,D=�	D6�AD=�(D,�*D=�/D3�1D=�6D:�8D=�=E!�E�E!c�<<�V^8�dQhRS[RS[RS[S[,/#�r�days�limitrB�rrr
)rrs"�rrr9�s.���������
 60  �n�	�	r!c��VP'gVP4\P!4P	4\VR7,
 61  pVPUu.uF@pVP'gKVP'gK+VPV8�gK>VNKB	ppVPRRR7VRV#uupi)z�
 62  Get episodes played in the last N days.
 63  
 64  Args:
 65      days: Look back this many days
 66      limit: Maximum episodes to return
 67  
 68  Returns:
 69      List of recently played episodes, sorted by user_updated_date descending
 70  )ruc�J�VP;'g\P#�N)rr�min)�eps&r�<lambda>�4OvercastParser.get_recently_played.<locals>.<lambda>�s��2�#7�#7�#G�#G�8�<�<�#Gr!T)�key�reverseN)	r<rNr�now�
 71  astimezonerrr�sort)r=rurv�cutoffr|�recents&&&   r�get_recently_played�"OvercastParser.get_recently_played�s����}�}�}��J�J�L�����*�*�,�y�d�/C�C�����
 72  �&�2��y�y�
��1�1�
�68�6J�6J�V�6S�
�B��	�
 73  �	���G�QU��V��f�u�~���
 74  s�%C�>C�C�%Cc�0<�V^8�dQhRS[S[,/#rArC)rrs"�rrr9�s���

 75  �

 76  ��n�!5�

 77  r!c���VP'gVP4VPUu.uF,pVP'dKVP^<8�gK*VNK.	up#uupi)zj
 78  Get episodes that are in progress (started but not finished).
 79  
 80  Returns:
 81      List of in-progress episodes
 82  )r<rNrr)r=r|s& r�get_in_progress�OvercastParser.get_in_progress�s\���}�}�}��J�J�L����
 83  �&�2��9�9�
�!#�!4�!4�r�!9�
�B��
 84  �	
 85  ��
 86  s�A&�
 87  A&�A&)r<r8r;N)��)r#r$r%r&r'r>rNrTr�r�r)r*r+s@rr6r63s>�����	1�	1���B2�2�h��<

 88  �

 89  r!r6c�a�]tRt^�toRtRV3RlRlltRV3RlRlltV3RlRltV3R	lR
 90  ltV3RlRlt	V3R
lRlt
 91  RtVtR#)�PodcastTrainingPipelinez/
 92  Full pipeline for podcast resonance training.
 93  Nc�<<�V^8�dQhRS[RS[RS[S[,/#)rr8�
 94  output_dir�transcript_dir)rr)rrs"�rr�$PodcastTrainingPipeline.__annotate__�s-���?�?��?��?�!��
�	?r!c��\V4Vn\V4VnV'd\V4MVPR,VnVPPRRR7VPPRRR7R#)z�
 95  Initialize the pipeline.
 96  
 97  Args:
 98      opml_path: Path to Overcast OPML export
 99      output_dir: Where to write training session notes
100      transcript_dir: Where to look for/store transcripts
101  �transcriptsT)�parents�exist_okN)r6�parserrr�r��mkdir)r=r8r�r�s&&&&rr>� PodcastTrainingPipeline.__init__�si��%�Y�/����z�*���6D�d�>�2�$�/�/�\i�Ji���	
�����d�T��:����!�!�$��!�>r!c�<<�V^8�dQhRS[RS[RS[S[,/#rtrw)rrs"�rrr��s3���G�G��G��G�
102  �n�	�	Gr!c�:�VPPWR7#)z�
103  Get episodes that are candidates for training.
104  
105  Args:
106      days: Look back this many days
107      limit: Maximum candidates
108  
109  Returns:
110      List of candidate episodes
111  �rurv)r�r�)r=rurvs&&&r�get_training_candidates�/PodcastTrainingPipeline.get_training_candidates�s���{�{�.�.�D�.�F�Fr!c�6<�V^8�dQhRS[RS[S[,/#)rr/rB)r
rr)rrs"�rrr��s���$�$�~�$�(�4�.�$r!c��a�\P!RRVP4P4pVP	4P4R,pVP\P!4R,.pVFopVP4'gKVPR4F?pVPP	4o\V3RlV44pV^8�gK;Vuu#	Kq	R#)z�
112  Find a transcript for an episode.
113  
114  Looks for:
115  - Podwise exports (markdown with podcast metadata)
116  - Manual transcripts
117  - Downloaded transcripts
118  
119  Args:
120      episode: The episode to find transcript for
121  
122  Returns:
123      Path to transcript or None
124  �[^\w\s-]rH�N�N�	Downloadsz*.mdc3�8<"�TFqS9gK^x�K	R#5i)�Nr")�.0�word�filename_lowers& �r�	<genexpr>�:PodcastTrainingPipeline.find_transcript.<locals>.<genexpr>s����R�K�D�>�;Q�a�a�K�s��
125  N)
�re�subr�strip�lower�splitr�r�home�exists�glob�stem�sum)	r=r/�title_normalized�title_words�search_dirs�
126  search_dir�md_file�matchesr�s	&&      @r�find_transcript�'PodcastTrainingPipeline.find_transcript�s���� �6�6�+�r�7�=�=�A�G�G�I��&�,�,�.�4�4�6�r�:��
����I�I�K�+�%�
127  ��
128  &�J��$�$�&�&��%�?�?�6�2��!(���!3�!3�!5���R�K�R�R���a�<�"�N�3�	&�r!c�H<�V^8�dQhRS[RS[RS[S[S[3,RS[/#)rr/�transcript_content�cognitive_fingerprintrB�r
rrr	)rrs"�rrr�s;������� �� $�C��H�~�	�
129  
130  
�r!c�J�\P!4PR4p\P!RRVP
131  4R,P
4pVRVR2pVPV,pVPWV4pVPV4\V4#)z�
132  Create a training session note in Obsidian format.
133  
134  Args:
135      episode: The episode
136      transcript_content: The transcript text
137      cognitive_fingerprint: Current cognitive fingerprint state
138  
139  Returns:
140      Path to created note
141  �%Y-%m-%dr�rH�N�2N�-z
-resonance.md)rr��strftimer�r�rr�r��_generate_training_note�
142  write_textr)	r=r/r�r��date_str�
143  safe_title�filename�filepath�note_contents	&&&&     r�create_training_session�/PodcastTrainingPipeline.create_training_sessions���"�<�<�>�*�*�:�6���V�V�K��W�]�]�;�C�@�F�F�H�
144  ��Z�q���M�:���?�?�X�-���3�3��)>�
145  ��	���L�)��8�}�r!c�H<�V^8�dQhRS[RS[RS[S[S[3,RS[/#)rr/�
146  transcript�fingerprintrBr�)rrs"�rrr�6sA���r�r��r��r��#�s�(�^�	r�
147  
148  
�rr!c��VPV4pRVPR\P!4P	R4RVP
149  RVPRVP'dVPP	R4MRR2p\VR	,^4FwrgVR
150  VRVR,R
2,
pK	VR,
p\VR,^4FwrgVR
151  VRVR,R
2,
pK	VR,
pVP4Fwr�VRVRV	R2,
pK	VRVP
152  RVPR2,
pV#)z$Generate the Obsidian training note.z!# Resonance Prediction Training: z
153  
154  **Date:** r�z
155  **Podcast:** z
156  **Episode:** z
157  **Listened:** rLa�
158  **Training Type:** Theory of Mind Calibration
159  
160  ---
161  
162  ## Purpose
163  
164  Training session for Sovereign OS Theory of Mind. Claude predicts which ideas resonated with Rick based on cognitive fingerprint. Rick reveals actual selections. Delta trains the model.
165  
166  ---
167  
168  ## Claude's Predictions
169  
170  *Predictions based on cognitive fingerprint analysis of transcript.*
171  
172  ### Tier 1: Highest Confidence (Predicted Strong Resonance)
173  
174  | Rank | Idea | Resonance Factors | Confidence |
175  |------|------|-------------------|------------|
176  r�z| z | :N�PNz ... | *To be analyzed* | 0.XX |
177  z�
178  ### Tier 2: Medium Confidence
179  
180  | Rank | Idea | Resonance Factors | Confidence |
181  |------|------|-------------------|------------|
182  :r��
183  Na�
184  
185  ---
186  
187  ## Rick's Actual Selections
188  
189  *Rick: Reorder these ideas by resonance. Add commentary on why.*
190  
191  ### Rick's Tier 1 (Strong Resonance)
192  
193  | Rank | Idea | Commentary |
194  |------|------|------------|
195  | 1 | | |
196  | 2 | | |
197  | 3 | | |
198  | 4 | | |
199  | 5 | | |
200  
201  ### Ideas Claude Missed Entirely
202  
203  *Things that resonated but Claude didn't predict:*
204  
205  | Idea | Why it resonated | What this reveals |
206  |------|------------------|-------------------|
207  | | | |
208  
209  ### Ideas Claude Over-Predicted
210  
211  *Things Claude thought would resonate but didn't:*
212  
213  | Idea | Why it didn't land | What this reveals |
214  |------|-------------------|-------------------|
215  | | | |
216  
217  ---
218  
219  ## Training Analysis
220  
221  *To be filled in after Rick's reveal:*
222  
223  ### Metrics
224  - **Precision:** ___
225  - **Recall:** ___
226  - **F1 Score:** ___
227  
228  ### Cognitive Fingerprint Updates
229  - New gravity wells:
230  - Pattern adjustments:
231  - Altitude distribution changes:
232  
233  ---
234  
235  ## Cognitive Fingerprint (Current State)
236  
237  z**z:** z
238  
239  z
240  ---
241  
242  *Training Session: z - z)*
243  *Sovereign OS Theory of Mind Pipeline*
244  )	�_extract_ideasrrr�r�rr�	enumerate�items)
245  r=r/r�r��ideas�note�i�idear�values
246  &&&&      rr��/PodcastTrainingPipeline._generate_training_note6s����#�#�J�/��4�W�]�]�O�D��<�<�>�"�"�:�.�
247  /�0��"�"�
#�$��m�m�_��AH�AZ�AZ�AZ�w�(�(�1�1�*�=�`i�j�k���4!��r��A�.�G�A��b���3�t�C�y�k�)J�K�K�D�/�	
��	��!��t��a�0�G�A��b���3�t�C�y�k�)J�K�K�D�1�	
�6�6	��p&�+�+�-�J�C��b���T�%���-�-�D�.�	
���(�(�)��W�]�]�O�<��	���r!c�6<�V^8�dQhRS[RS[S[,/#)rr�rB)rr)rrs"�rrr��s��������c��r!c��\P!RV4pVUu.uFZp\VP44^d8�gK#VP4P	R4'dKJVP4NK\	ppVR,#uupi)zl
248  Extract key ideas from transcript.
249  
250  Simple extraction - real implementation would use NLP/ContentAnalyzer.
251  z\n\n+�#:Nr�N)r�r��lenr��
252  startswith)r=r��
253  paragraphs�pr�s&&   rr��&PodcastTrainingPipeline._extract_ideas�sy���X�X�h�
254  �3�
255  � *�
256  �)�!��1�7�7�9�~��#�
�,-�G�G�I�,@�,@��,E�
�A�G�G�I�z�	�
257258  �S�z���
259  s� B�"B�(B)r�r�r�rz)�r�)
r#r$r%r&r'r>r�r�r�r�r�r)r*r+s@rr�r��sL�����?�?�,G�G�"$�$�L��<r�r�h�r!r��__main__z'=== Podcast Training Pipeline Test ===
260  z~/Downloads/overcast.opmlzOPML not found at zParsed z total episodes
261  r�zRecently Played (last 30 days):r�rLz  [z] z: r�z...z
262  In Progress: z	 episodesr�z  :N�(Nz... (z min in)z
263  === Test Complete ===)0r'�xml.etree.ElementTree�etree�ElementTreerM�dataclassesrrrr�typingrrrr	r
264  �pathlibrr�rgr
r-r6r�r#�osrl�path�
265  expanduserr8r��exitr�rNr<r�r�r�r|rr�r�rrr��in_progressr�minsr"r!r�<module>r�s����"#�"�(�(�3�3��	���
266  (�
267  (��
268  (��$�$��$�P
269  �P
270  �fs�s�n�z��
�	�
271  4�5����"�"�#>�?�I�
�7�7�>�>�)�$�$�
�"�9�+�.�/��Q���I�
&�F��|�|�~�H�	�G�C��M�?�"3�
272  4�5��
'�
'�R�r�
'�
:�F�	�
273  +�,���@B�@T�@T�@T�2�'�'�0�0��<�Zc��
��H�:�R����0��2�8�8�C�=�/��E�F��
274  �(�(�*�K�	�O�C��,�-�Y�
275  7�8��"�o�o���"�"�b�(��
��2�8�8�C�=�/��t�f�H�5�6��
276277  #�$�=r!