@@ -587,32 +587,57 @@ def index_visuals(
587587
588588 def index_audio (
589589 self ,
590+ prompt : Optional [str ] = None ,
591+ model_name : Optional [str ] = None ,
592+ model_config : Optional [Dict ] = None ,
590593 language_code : Optional [str ] = None ,
591- segmentation_type : Optional [SegmentationType ] = SegmentationType .sentence ,
592- force : bool = False ,
593- callback_url : str = None ,
594- ) -> None :
595- """Index audio (spoken words) in the video.
596-
597- :param str language_code: (optional) Language code of the video
598- :param SegmentationType segmentation_type: (optional) Segmentation type used for indexing, :class:`SegmentationType <SegmentationType>` object
599- :param bool force: (optional) Force to index the video
594+ batch_config : Optional [Dict ] = None ,
595+ name : Optional [str ] = None ,
596+ callback_url : Optional [str ] = None ,
597+ ) -> Optional [str ]:
598+ """Index audio by processing transcript segments through an LLM.
599+
600+ Segments the video transcript, processes each segment with the given
601+ prompt using the specified model, and indexes the results as scene
602+ records for semantic search.
603+
604+ :param str prompt: (optional) Prompt for processing transcript segments
605+ :param str model_name: (optional) LLM tier to use (e.g. "basic", "pro", "ultra")
606+ :param dict model_config: (optional) Model configuration
607+ :param str language_code: (optional) Language code for transcription
608+ :param dict batch_config: (optional) Segmentation config with keys:
609+ - "type": Segmentation type ("word", "sentence", or "time")
610+ - "value": Segment length (words, sentences, or seconds)
611+ Defaults to {"type": "word", "value": 10}
612+ :param str name: (optional) Name for the scene index
600613 :param str callback_url: (optional) URL to receive the callback
601- :raises InvalidRequestError: If the video is already indexed
602- :return: None if the indexing is successful
603- :rtype: None
614+ :return: The scene index id
615+ :rtype: str
604616 """
605- self ._connection .post (
606- path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .index } " ,
617+ if batch_config is None :
618+ batch_config = {"type" : Segmenter .word , "value" : 10 }
619+
620+ extraction_config = {
621+ "segmenter" : batch_config .get ("type" , Segmenter .word ),
622+ "segmentation_value" : batch_config .get ("value" , 10 ),
623+ }
624+
625+ scenes_data = self ._connection .post (
626+ path = f"{ ApiPath .video } /{ self .id } /{ ApiPath .index } /{ ApiPath .scene } " ,
607627 data = {
608- "index_type" : IndexType .spoken_word ,
628+ "extraction_type" : SceneExtractionType .transcript ,
629+ "extraction_config" : extraction_config ,
630+ "prompt" : prompt ,
631+ "model_name" : model_name ,
632+ "model_config" : model_config ,
609633 "language_code" : language_code ,
610- "segmentation_type" : segmentation_type ,
611- "force" : force ,
634+ "name" : name ,
612635 "callback_url" : callback_url ,
613636 },
614- show_progress = True ,
615637 )
638+ if not scenes_data :
639+ return None
640+ return scenes_data .get ("scene_index_id" )
616641
617642 def list_scene_index (self ) -> List :
618643 """List all the scene indexes.
0 commit comments