(self, wavfile)
Get audio data and sample rate from a wavfile.
    :param wavfile: filepath of wav.
    :return: 2 values. The first is a Tensor of audio data.
        The second return value isthe sample rate of the input wav
        file, which is a tensor with float dtype.
Get audio data and sample rate from a wavfile.
    :param wavfile: filepath of wav.
    :return: 2 values. The first is a Tensor of audio data.
        The second return value isthe sample rate of the input wav
        file, which is a tensor with float dtype.
Get audio data and sample rate from a wavfile . : param wavfile : filepath of wav . : return : 2 values . The first is a Tensor of audio data . The second return value isthe sample rate of the input wav file which is a tensor with float dtype .
def call(self, wavfile):
    """
    Get audio data and sample rate from a wavfile.
    :param wavfile: filepath of wav.
    :return: 2 values. The first is a Tensor of audio data.
        The second return value isthe sample rate of the input wav
        file, which is a tensor with float dtype.
    """
    p = self.config
    contents = tf.io.read_file(wavfile)
    audio_data, sample_rate = tf.audio.decode_wav(
        contents, desired_channels=p.audio_channels)
    assert_op = tf.assert_equal(
        tf.constant(p.sample_rate), tf.cast(sample_rate, dtype=tf.int32))

    with tf.control_dependencies([assert_op]):

      if p.speed == 1.0:
        return tf.squeeze(
            audio_data * 32768, axis=-1), tf.cast(
                sample_rate, dtype=tf.int32)
      else:
        resample_rate = tf.cast(
            sample_rate, dtype=tf.float32) * tf.cast(
                1.0 / p.speed, dtype=tf.float32)
        speed_data = py_x_ops.speed(
            tf.squeeze(audio_data * 32768, axis=-1),
            tf.cast(sample_rate, dtype=tf.int32),
            tf.cast(resample_rate, dtype=tf.int32),
            lowpass_filter_width=5)
        return tf.squeeze(speed_data), tf.cast(sample_rate, dtype=tf.int32)
def call ( self , wavfile ) : p = self . config contents = tf . io . read_file ( wavfile ) audio_data , sample_rate = tf . audio . decode_wav ( contents , desired_channels = p . audio_channels ) assert_op = tf . assert_equal ( tf . constant ( p . sample_rate ) , tf . cast ( sample_rate , dtype = tf . int32 ) ) with tf . control_dependencies ( [ assert_op ] ) : if p . speed == 1.0 : return tf . squeeze ( audio_data * 32768 , axis = - 1 ) , tf . cast ( sample_rate , dtype = tf . int32 ) else : resample_rate = tf . cast ( sample_rate , dtype = tf . float32 ) * tf . cast ( 1.0 / p . speed , dtype = tf . float32 ) speed_data = py_x_ops . speed ( tf . squeeze ( audio_data * 32768 , axis = - 1 ) , tf . cast ( sample_rate , dtype = tf . int32 ) , tf . cast ( resample_rate , dtype = tf . int32 ) , lowpass_filter_width = 5 ) return tf . squeeze ( speed_data ) , tf . cast ( sample_rate , dtype = tf . int32 )