欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

sph2pipe用法

程序员文章站 2022-05-27 19:57:37
...
  • example
import subprocess
import os

def nist2wav(src_dir):
    count = 0
    for subdir, dirs, files in os.walk(src_dir):
        for f in files:
            fullFilename = os.path.join(subdir, f)
            if f.endswith('.wv1') or f.endswith('.wv2') or f.endswith('.WAV'):
                count += 1
                os.rename(fullFilename,fullFilename+".WAV")
                os.system("./sph2pipe "+fullFilename+".WAV"+" -f rif " +fullFilename)
                os.remove(fullFilename+".WAV")
                print(fullFilename)

if __name__ == '__main__':
    nist2wav('/storage/workspace/zhujieenv/Automatic_Speech_Recognition/speechvalley/data/data/lisa/data/timit/raw/TIMIT')

说明:

  1. /storage/workspace/zhujieenv/Automatic_Speech_Recognition/speechvalley/data/data/lisa/data/timit/raw/TIMIT为包含sph文件的目录,某个子目录包含的文件为SA1.PHN、SA1.TXT、SA1.WRD、SA1.WAV
  2. SA1.PHN:
0 9640 h#
9640 11240 sh
11240 12783 iy
12783 14078 hv
14078 16157 ae
16157 16880 dcl
16880 17103 d
17103 17587 y
17587 18760 er
18760 19720 dcl
19720 19962 d
19962 21514 aa
21514 22680 r
22680 23800 kcl
23800 24104 k
24104 26280 s
26280 28591 uw
28591 29179 dx
29179 30337 ih
30337 31880 ng
31880 32500 gcl
32500 33170 g
33170 33829 r
33829 35150 iy
35150 37370 s
37370 38568 iy
38568 40546 w
40546 42357 aa
42357 45119 sh
45119 45624 epi
45624 46855 w
46855 48680 aa
48680 49240 dx
49240 51033 er
51033 52378 q
52378 54500 ao
54500 55461 l
55461 57395 y
57395 59179 iy
59179 60600 axr
60600 63440 h#
  1. SA1.TXT:
0 63488 She had your dark suit in greasy wash water all year.
  1. SA1.WRD:
9640 12783 she
12783 17103 had
17103 18760 your
18760 24104 dark
24104 29179 suit
29179 31880 in
31880 38568 greasy
38568 45119 wash
45624 51033 water
52378 55461 all
55461 60600 year