zoukankan      html  css  js  c++  java
  • 对TIMIT数据进行格式转换(SPHERE2WAV(RIFF))

    首先,转换sph2pipe工具所在文件夹(此工具为LDC所提供的SPHERE音频文件转换工具)
    cd '/home/dream/Research/kaldi-master/tools/sph2pipe_v2.5'
    其次:在命令行进行音频文件转换测试:
    ./sph2pipe -f wav ./wav_test/SA1.WAV ./wav_test/SA1_tr.WAV
    此处需要注意的是,sph2pipe可执行文件不再PATH当中,所以需要当前路径下的完全路径,即:./sph2pipe才可以运行,而非sph2pipe。

    1.由批处理python脚本生成转换文件
    具体的:

    # encoding:utf-8
    import os
    import os.path
    
    root_dir = "/home/dream/Research/Data/TIMIT/"
    
    timit_path = "/home/dream/Research/Data/TIMIT/"
    # 文件保存路径
    
    sph2pipe_path = "/home/dream/Research/kaldi-master/tools/sph2pipe_v2.5/sph2pipe"
    # sph2pipe工具所在路径
    
    f = open("/home/dream/Research/Data/timit_sph2pipe/make_sph2pipe_file.txt", 'w')
    
    for root, dirs, files in os.walk(root_dir):
    	for fn in files:
    		if fn[len(fn)-3:len(fn)]=='WAV':
    			sourcefile = timit_path+root[len(root_dir):]+"/"+fn
    			targetfile = root[len(root)-5:len(root)]+"_"+fn
    			s = sph2pipe_path + " -f wav " + sourcefile+" "+targetfile+"
    "
    			f.write(s.replace('\','/'))
    f.close()
    

    由上述脚本,可以生成对应的txt格式的转换文件
    2.在linux下运行shell脚本文件,读取转换文件进行数据转换

    # 逐行执行make_sph2pipe_file.txt当中的命令
    filename='/home/dream/Research/Data/timit_sph2pipe/text.txt'
    while read line
    do 
    	echo $line
    	$line
            # 此处$line进行逐行执行代码 
    done < $filename
    
  • 相关阅读:
    如何使用Flannel搭建跨主机互联的容器网络
    移动端——touch事件
    Javascript 模块化指北
    vue重构--H5--canvas实现粒子时钟
    redux-saga框架使用详解及Demo教程
    前端代码编写规范
    探秘JS的异步单线程
    POJ 3714 Raid 近期对点题解
    EditText把回车键变成搜索
    Swift语言概览
  • 原文地址:https://www.cnblogs.com/dream-and-truth/p/10413575.html
Copyright © 2011-2022 走看看