
    Pi`                     4   d Z ddlZddlmZ ddlmZ  ee          j        dz  Zedz  edz  edz  ed	z  ed
z  gZ	dde
dee
         de
fdZddee
         de
fdZddee
         de
fdZddee
         de
fdZddee
         de
fdZddee
         de
fdZdS )a2  
Media Registry for Gradio Demos

This module provides a centralized way to access media files.

Usage:
    from gradio.media import get_image, get_video, get_audio, get_model3d, get_file

    # Get specific media files
    cheetah_img = get_image("cheetah1.jpg")
    world_video = get_video("world.mp4")
    cantina_audio = get_audio("cantina.wav")
    bunny_model = get_model3d("Bunny.obj")
    titanic_data = get_file("titanic.csv")

    # Get random media of a type
    random_img = get_image()
    random_video = get_video()
    random_audio = get_audio()

    N)Path)Optionalmedia_assetsimagesvideosaudiomodels3ddata
media_typefilenamereturnc                    t           | z  }|                                st          d|           |Kt          |                    d                    }|st          d|           t          j        |          }n|                    d          r|S ||z  }|                                st          d|           t          |
                                          S )a  
    Internal function to get the path to a media file.

    Args:
        media_type: Type of media (images, videos, audio, models3d, data)
        filename: Optional filename of the media file. If None, returns a random file.

    Returns:
        Absolute path to the media file

    Raises:
        ValueError: If media_type is invalid
        FileNotFoundError: If the media file doesn't exist
    zMedia directory not found: N*zNo media files found in )zhttp://zhttps://zMedia file not found: )
MEDIA_ROOTexists
ValueErrorlistglobrandomchoice
startswithFileNotFoundErrorstrabsolute)r   r   	media_dirmedia_files	file_paths        `/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/gradio/media.py_get_media_pathr   %   s     Z'I DByBBCCC9>>#..// 	EC	CCDDDM+..		677 	O(	 F D D DEEEy!!##$$$    c                 "    t          d|           S )a7  
    Get path to an image file.

    Args:
        filename: Filename of the image (e.g., "tower.jpg"). If None, returns a random image.

    Returns:
        Absolute path to the image file

    Examples:
        >>> get_image("tower.jpg")  # Get specific image
        >>> get_image()  # Get random image
    r   r   r   s    r   	get_imager$   K        8X...r    c                 "    t          d|           S )a6  
    Get path to a video file.

    Args:
        filename: Filename of the video (e.g., "world.mp4"). If None, returns a random video.

    Returns:
        Absolute path to the video file

    Examples:
        >>> get_video("world.mp4")  # Get specific video
        >>> get_video()  # Get random video
    r   r"   r#   s    r   	get_videor'   \   r%   r    c                 "    t          d|           S )a@  
    Get path to an audio file.

    Args:
        filename: Filename of the audio (e.g., "cantina.wav"). If None, returns a random audio file.

    Returns:
        Absolute path to the audio file

    Examples:
        >>> get_audio("cantina.wav")  # Get specific audio
        >>> get_audio()  # Get random audio
    r   r"   r#   s    r   	get_audior)   m   s     7H---r    c                 "    t          d|           S )aD  
    Get path to a 3D model file.

    Args:
        filename: Filename of the 3D model (e.g., "Duck.glb"). If None, returns a random model.

    Returns:
        Absolute path to the 3D model file

    Examples:
        >>> get_model3d("Duck.glb")  # Get specific model
        >>> get_model3d()  # Get random 3D model
    r	   r"   r#   s    r   get_model3dr+   ~   s     :x000r    c                 "    t          d|           S )aT  
    Get path to a data file (CSV, JSON, text, etc.).

    Args:
        filename: Filename of the data file (e.g., "titanic.csv"). If None, returns a random file.

    Returns:
        Absolute path to the data file

    Examples:
        >>> get_file("titanic.csv")  # Get specific file
        >>> get_file()  # Get random data file
    r
   r"   r#   s    r   get_filer-      s     68,,,r    )N)__doc__r   pathlibr   typingr   __file__parentr   MEDIA_PATHSr   r   r$   r'   r)   r+   r-    r    r   <module>r5      s   ,             T(^^"^3
#% #% #%x} #% #% #% #% #%L/ / / / / / /"/ / / / / / /". . . . . . ."1 1(3- 13 1 1 1 1"- -x} - - - - - - -r    