File: test_s2mfc.py

package info (click to toggle)
sphinxtrain 5.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,572 kB
  • sloc: ansic: 94,052; perl: 8,939; python: 6,702; cpp: 2,044; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 774 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
#!/usr/bin/env python

import unittest
import tempfile
from cmusphinx import s2mfc
import os


class TestS2MFC(unittest.TestCase):
    def setUp(self):
        thisdir = os.path.dirname(__file__)
        self.testdir = os.path.join(thisdir, 'data')

    def test_mfcfile(self):
        with s2mfc.open(os.path.join(self.testdir, "sa1.mfc")) as s2f:
            mfcc = s2f.getall()
            self.assertAlmostEqual(mfcc.mean(0)[0], 7.58447343)
        with tempfile.NamedTemporaryFile() as nt:
            with s2mfc.open(nt.name, "w") as s2f:
                s2f.writeall(mfcc)
            with s2mfc.open(nt.name) as s2f:
                mfcc = s2f.getall()
            self.assertAlmostEqual(mfcc.mean(0)[0], 7.58447343)


if __name__ == '__main__':
    unittest.main()