@@ -49,7 +49,7 @@ def _duration_to_minutes(self, duration: PodcastDuration) -> int:
4949 }
5050 return duration_mapping [duration ]
5151
52- def generate_podcast_from_pdf (self , pdf_url : str , speakers : list [SpeakerWithVoiceId ], duration : PodcastDuration = PodcastDuration .SHORT , language : str = "english" , start_page : Optional [int ] = None , end_page : Optional [int ] = None ) -> Podcast :
52+ def generate_podcast_from_pdf (self , pdf_url : str , speakers : list [SpeakerWithVoiceId ], duration : PodcastDuration = PodcastDuration .SHORT , language : str = "english" , start_page : Optional [int ] = None , end_page : Optional [int ] = None , podcast_id : Optional [ str ] = None ) -> Podcast :
5353 """
5454 Generate a podcast for a given PDF file and speakers.
5555
@@ -106,11 +106,11 @@ def generate_podcast_from_pdf(self, pdf_url: str, speakers: list[SpeakerWithVoic
106106 elif end_page :
107107 title += f" (Up to Page { end_page } )"
108108
109- url = self ._s3_storage_service .upload_podcast_audio (audio , title )
109+ url = self ._s3_storage_service .upload_podcast_audio (audio , title , podcast_id )
110110
111111 return Podcast (title = title , duration_minutes = self .calculate_audio_duration (audio ), audio_url = url , script = script_response .script )
112112
113- def generate_podcast_from_image (self , image_url : str , speakers : list [SpeakerWithVoiceId ], duration : PodcastDuration = PodcastDuration .SHORT , language : str = "english" ) -> Podcast :
113+ def generate_podcast_from_image (self , image_url : str , speakers : list [SpeakerWithVoiceId ], duration : PodcastDuration = PodcastDuration .SHORT , language : str = "english" , podcast_id : Optional [ str ] = None ) -> Podcast :
114114 """
115115 Generate a podcast for a given image and speakers.
116116
@@ -164,11 +164,11 @@ def generate_podcast_from_image(self, image_url: str, speakers: list[SpeakerWith
164164
165165 # Use AI-generated title or create a fallback
166166 title = script_response .title if script_response .title else "Image Analysis Podcast"
167- url = self ._s3_storage_service .upload_podcast_audio (audio , title )
167+ url = self ._s3_storage_service .upload_podcast_audio (audio , title , podcast_id )
168168
169169 return Podcast (title = title , duration_minutes = self .calculate_audio_duration (audio ), audio_url = url , script = script_response .script )
170170
171- def generate_podcast_from_topic (self , topic : str , speakers : list [SpeakerWithVoiceId ], duration : PodcastDuration = PodcastDuration .SHORT , language : str = "english" ) -> Podcast :
171+ def generate_podcast_from_topic (self , topic : str , speakers : list [SpeakerWithVoiceId ], duration : PodcastDuration = PodcastDuration .SHORT , language : str = "english" , podcast_id : Optional [ str ] = None ) -> Podcast :
172172 """
173173 Generate a podcast for a given topic and speakers.
174174 """
@@ -195,11 +195,11 @@ def generate_podcast_from_topic(self, topic: str, speakers: list[SpeakerWithVoic
195195 ))
196196
197197 audio = self ._elevenlabs_client .generate_podcast_audio (conversations )
198- url = self ._s3_storage_service .upload_podcast_audio (audio , topic )
198+ url = self ._s3_storage_service .upload_podcast_audio (audio , topic , podcast_id )
199199
200200 return Podcast (title = topic , duration_minutes = self .calculate_audio_duration (audio ), audio_url = url , script = script .script )
201201
202- def generate_podcast_from_website (self , website_url : str , speakers : list [SpeakerWithVoiceId ], duration : PodcastDuration = PodcastDuration .SHORT , language : str = "english" ) -> Podcast :
202+ def generate_podcast_from_website (self , website_url : str , speakers : list [SpeakerWithVoiceId ], duration : PodcastDuration = PodcastDuration .SHORT , language : str = "english" , podcast_id : Optional [ str ] = None ) -> Podcast :
203203 """
204204 Generate a podcast for a given website and speakers.
205205
@@ -245,7 +245,7 @@ def generate_podcast_from_website(self, website_url: str, speakers: list[Speaker
245245
246246 # Use the website URL as title
247247 title = website_url
248- url = self ._s3_storage_service .upload_podcast_audio (audio , title )
248+ url = self ._s3_storage_service .upload_podcast_audio (audio , title , podcast_id )
249249
250250 return Podcast (title = title , duration_minutes = self .calculate_audio_duration (audio ), audio_url = url , script = script .script )
251251
@@ -255,15 +255,18 @@ def generate_podcast(self,
255255 duration : PodcastDuration = PodcastDuration .SHORT ,
256256 language : str = "english" ,
257257 start_page : Optional [int ] = None ,
258- end_page : Optional [int ] = None ) -> Podcast :
258+ end_page : Optional [int ] = None ,
259+ podcast_id : Optional [str ] = None ) -> Podcast :
259260 if type == PodcastType .TOPIC :
260- return self .generate_podcast_from_topic (source_content , speakers , duration , language )
261+ return self .generate_podcast_from_topic (source_content , speakers , duration , language , podcast_id )
261262 elif type == PodcastType .PDF_DOCUMENT :
262- return self .generate_podcast_from_pdf (source_content , speakers , duration , language , start_page , end_page )
263+ return self .generate_podcast_from_pdf (source_content , speakers , duration , language , start_page , end_page , podcast_id )
263264 elif type == PodcastType .PHOTO :
264- return self .generate_podcast_from_image (source_content , speakers , duration , language )
265+ return self .generate_podcast_from_image (source_content , speakers , duration , language , podcast_id )
265266 elif type == PodcastType .WEBSITE_LINK :
266- return self .generate_podcast_from_website (source_content , speakers , duration , language )
267+ return self .generate_podcast_from_website (source_content , speakers , duration , language , podcast_id )
268+ else :
269+ raise ValueError (f"Unsupported podcast type: { type } " )
267270
268271 def calculate_audio_duration (self , audio : bytes ) -> int :
269272 """
0 commit comments