
    &VfN                     F    d Z ddlZddlmZ ddlmZ ddlmZ 	 	 	 	 ddZ	dS )	a  Audio summaries and TensorFlow operations to create them, V2 versions.

An audio summary stores a rank-2 string tensor of shape `[k, 2]`, where
`k` is the number of audio clips recorded in the summary. Each row of
the tensor is a pair `[encoded_audio, label]`, where `encoded_audio` is
a binary string whose encoding is specified in the summary metadata, and
`label` is a UTF-8 encoded Markdown string describing the audio clip.
    N)tf2)metadata)lazy_tensor_creator   c                 $   t          t          dd          ddlm |d}|dk    rt	          d|z            t          j        d|t
          j                            d                    }|g}t          t          j	        j
        d	d          pt          j	        j        }	 |	| d
|          5 \  }
}t          j        fd            }t          j	                            |
|||          cddd           S # 1 swxY w Y   dS )a  Write an audio summary.

    Arguments:
      name: A name for this summary. The summary tag used for TensorBoard will
        be this name prefixed by any active name scopes.
      data: A `Tensor` representing audio data with shape `[k, t, c]`,
        where `k` is the number of audio clips, `t` is the number of
        frames, and `c` is the number of channels. Elements should be
        floating-point values in `[-1.0, 1.0]`. Any of the dimensions may
        be statically unknown (i.e., `None`).
      sample_rate: An `int` or rank-0 `int32` `Tensor` that represents the
        sample rate, in Hz. Must be positive.
      step: Explicit `int64`-castable monotonic step value for this summary. If
        omitted, this defaults to `tf.summary.experimental.get_step()`, which must
        not be None.
      max_outputs: Optional `int` or rank-0 integer `Tensor`. At most this
        many audio clips will be emitted at each step. When more than
        `max_outputs` many clips are provided, the first `max_outputs`
        many clips will be used and the rest silently discarded.
      encoding: Optional constant `str` for the desired encoding. Only "wav"
        is currently supported, but this is not guaranteed to remain the
        default, so if you want "wav" in particular, set this explicitly.
      description: Optional long-form description for this summary, as a
        constant `str`. Markdown is supported. Defaults to empty.

    Returns:
      True on success, or false if no summary was emitted because no default
      summary writer was available.

    Raises:
      ValueError: if a default writer exists, but no step was provided and
        `tf.summary.experimental.get_step()` is None.
    audioNr   )gen_audio_opswavzUnknown encoding: %rWAV)display_namedescriptionencodingsummary_scopeaudio_summary)valuesc                  4   t           j                            d           t           j                                       d          } t	          j        j                  }t          j        || t           j        d          t          j	        t          j
                  d         dk    fdd           t          j        d	gt          j
        |           d d
                   }t          j        t          j        |g                    S )Nr   )sample_rateencode_each_audio)dtypename)inputr   c                       S N )encoded_audios   a/var/www/html/software/conda/lib/python3.11/site-packages/tensorboard/plugins/audio/summary_v2.py<lambda>z,audio.<locals>.lazy_tensor.<locals>.<lambda>s   s         c                  @    t          j        g t           j                  S r   )tfconstantstringr   r   r   r   z,audio.<locals>.lazy_tensor.<locals>.<lambda>t   s    B	22 r       )a)r    	debuggingassert_rankassert_non_negative	functoolspartial
encode_wavmap_fnr"   condshapetile	transposestack)limited_audio	encode_fnlimited_labelsr   	audio_opsdatamax_outputsr   s      @r   lazy_tensorzaudio.<locals>.lazy_tensorb   s   L$$T1---L,,[999 +.M!)$+  I Ii(	  M G}---a014%%%%22 M
  WbT28-+H+H+H!+LMMN<"(M>+J"K"KLLLLr   )tagtensorstepr   )getattrr    tensorflow.python.opsr	   
ValueErrorr   create_summary_metadataEncodingValuesummaryexperimentalr   r   LazyTensorCreatorwrite)r   r6   r   r;   r7   r   r   summary_metadatainputsr   r9   _r8   r5   s    `` `        @r   r   r       s   T GT**IDDDDDD5/(:;;;7"((//  
 Kd3F 	
'$?? 	$:#  
t_V	<	<	< 
a 
	.	M 	M 	M 	M 	M 	M 	M 
/	.	M0 zKd=M   
 
;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   8A DD	D	)Nr   NN)
__doc__r)   tensorboard.compatr   r    tensorboard.plugins.audior   tensorboard.utilr   r   r   r   r   <module>rM      s         ( ( ( ( ( ( . . . . . . 0 0 0 0 0 0 
]
 ]
 ]
 ]
 ]
 ]
r   