Пример #1
0
 def test_detla_delta(self):
   ''' test delta delta'''
   with self.session():
     feat = tf.constant(self.data[None, :], dtype=tf.float32)
     output = py_x_ops.delta_delta(feat, order=self.order, window=self.window)
     self.assertEqual(tf.rank(output).eval(), tf.rank(feat).eval())
     self.assertEqual(output.shape, (1, self.feat_dim * (self.order + 1)))
     self.assertAllClose(output.eval(), self.output_true[None, :])
Пример #2
0
    def call(self, feat, order, window):
        """
    Caculate delta of feats.
    :param feat: a float tensor of size (num_frames, dim_feat).
    :param order: an int.
    :param window: an int.
    :return: A tensor with shape (num_frames, (dim_feat * (order + 1))),
        containing delta of features of every frame in speech.
    """

        p = self.config
        with tf.name_scope('delta_delta'):
            delta_delta = py_x_ops.delta_delta(feat, order, window)

        return delta_delta
Пример #3
0
def delta_delta(feat, order=2):
    '''
  params:
    feat: a tensor of shape [nframe, nfbank] or [nframe, nfbank, 1]
  return: [nframe, nfbank, 3]
  '''
    feat = tf.cond(tf.equal(tf.rank(feat), 3),
                   true_fn=lambda: feat[:, :, 0],
                   false_fn=lambda: feat)

    shape = tf.shape(feat)
    # [nframe nfbank*3]
    nframe = shape[0]
    nfbank = shape[1]
    delta = py_x_ops.delta_delta(feat, order=order)
    feat_with_delta_delta = tf.reshape(delta, (nframe, nfbank, (order + 1)))
    return feat_with_delta_delta