autorag.audio_source¶
- class autorag.audio_source.AudioSource(path, source_url, video_id, title=None, upload_date=None, duration_s=None, uploader=None)[source]¶
Bases:
objectResolved audio input plus its original-source identity and metadata.
pathis the local file the rest of the pipeline reads.source_urlandvideo_idare populated only when the input was a YouTube URL. The remaining fields surface yt-dlp’s info dict (title, upload date, duration, uploader) so downstream persistence can record human-readable metadata instead of falling back to the temp filename / mtime.- Parameters:
- autorag.audio_source.is_youtube_url(value)[source]¶
Return True iff
valueparses as an http(s) URL on a YouTube host.
- autorag.audio_source.default_title_from(source)[source]¶
Derive a clip title from a local path or YouTube URL.
YouTube URLs resolve to the video id; local paths resolve to the file stem. Used as a fallback when neither a caller-supplied title nor a yt-dlp-provided title is available.
- autorag.audio_source.resolve_audio_input(source)[source]¶
Yield an
AudioSourceforsource.If
sourceis a YouTube URL, download the best audio stream into a temporary directory and yield a populatedAudioSourcewhosepathpoints into that tempdir. The tempdir is removed on exit. Otherwise treatsourceas a local path and yield a path-onlyAudioSourceafter verifying the file exists.- Parameters:
- Return type: