(waveforms, params)
return batch_feats
waveforms: [batch, samples, audio_channels]
  return: features [batch, nframes, feat_size, channles]
waveforms: [batch, samples, audio_channels]
  return: features [batch, nframes, feat_size, channles]
waveforms : [ batch samples audio_channels ] return : features [ batch nframes feat_size channles ]
def batch_extract_feature(waveforms, params):
  ''' waveforms: [batch, samples, audio_channels]
  return: features [batch, nframes, feat_size, channles]
  '''

  def _to_tensor_array(name, v, clear_after_read=None):
    ''' create TensorArray from v, of size batch.'''
    ta = tf.TensorArray(
        v.dtype, batch, name=name, clear_after_read=clear_after_read)
    ta = ta.unstack(v)
    return ta

  def _loop_continue(time, inputs, unused_output_tas):
    del unused_output_tas
    batch = tf.shape(inputs)[0]
    return time < batch

  def _loop_body(time, inputs, output_tas):
    feat = extract_feature(inputs[time, ...], params)
    new_output_tas = output_tas.write(time, feat)
    return (time + 1, inputs, new_output_tas)

  batch = tf.shape(waveforms)[0]
  output_tas = _new_tensor_array('batch_feat', batch, dtype=tf.float32)
  time = tf.constant(0, tf.int32)
  loop_vars = (time, waveforms, output_tas)

  parallel_iterations = 10
  shape_invariants = tf.nest.map_structure(lambda t: tf.TensorShape(None),
                                           loop_vars)

  (time, inputs, output_tas) = tf.while_loop(
      _loop_continue,
      _loop_body,
      loop_vars=loop_vars,
      shape_invariants=shape_invariants,
      parallel_iterations=parallel_iterations,
      swap_memory=False)
  del inputs

  batch_feats = output_tas.stack()
  return batch_feats
def batch_extract_feature ( waveforms , params ) : def _to_tensor_array ( name , v , clear_after_read = None ) : ''' create TensorArray from v, of size batch.''' ta = tf . TensorArray ( v . dtype , batch , name = name , clear_after_read = clear_after_read ) ta = ta . unstack ( v ) return ta def _loop_continue ( time , inputs , unused_output_tas ) : del unused_output_tas batch = tf . shape ( inputs ) [ 0 ] return time < batch def _loop_body ( time , inputs , output_tas ) : feat = extract_feature ( inputs [ time , ... ] , params ) new_output_tas = output_tas . write ( time , feat ) return ( time + 1 , inputs , new_output_tas ) batch = tf . shape ( waveforms ) [ 0 ] output_tas = _new_tensor_array ( 'batch_feat' , batch , dtype = tf . float32 ) time = tf . constant ( 0 , tf . int32 ) loop_vars = ( time , waveforms , output_tas ) parallel_iterations = 10 shape_invariants = tf . nest . map_structure ( lambda t : tf . TensorShape ( None ) , loop_vars ) ( time , inputs , output_tas ) = tf . while_loop ( _loop_continue , _loop_body , loop_vars = loop_vars , shape_invariants = shape_invariants , parallel_iterations = parallel_iterations , swap_memory = False ) del inputs batch_feats = output_tas . stack ( ) return batch_feats