File: _1s_c_d_dd.py

package info (click to toggle)
sphinxtrain 5.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 32,572 kB
  • sloc: ansic: 94,052; perl: 8,939; python: 6,702; cpp: 2,044; makefile: 6
file content (40 lines) | stat: -rw-r--r-- 1,142 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright (c) 2006 Carnegie Mellon University
#
# You may copy and modify this freely under the same terms as
# Sphinx-III

"""Compute Sphinx-III 1s_c_d_dd features.

This module provides a compute() function to compute 39-dimensional
single-stream features consisting of cepstra and their first and
second time derivatives.  This is the default feature type used for
Sphinx-III continuous density acoustic models.
"""

__author__ = "David Huggins-Daines <dhuggins@cs.cmu.edu>"
__version__ = "$Revision$"

from numpy import zeros, concatenate

def compute(mfcc):
    """Compute 39-dimensional single-stream features consisting of cepstra
     and their first and second time derivatives."""
    r, c = mfcc.shape

    # Pad the features to compute dcep, ddcep
    pad = concatenate((zeros((3,c)), mfcc, zeros((3,c))))

    # Now create the output array
    feat = zeros((r, c*3),'d')

    # cep
    feat[:, 0:13] = mfcc
    
    # dcep = mfc[2] - mfc[-2]
    feat[:, 13:26] = (pad[5:-1] - pad[1:-5])

    # ddcep = (mfc[3] - mfc[-1]) - (mfc[1] - mfc[-3])
    feat[:, 26:] = (pad[6:] - pad[2:-4]) - (pad[4:-2] - pad[0:-6])

    return feat