TIMIT语音库为大多数论文及研究中常用的语音库,适用于语音识别、说话人识别等语音信号处理。
在MIT网站可以找到一些样例, 为 16kHz sampling, 16 bit sample, PCM encoding。样例才160个句子,不够用。
这儿能找到完整版,用抓取工具全部下载下来有600多M
但问题是虽然其为wav结尾,matlab中wavread却读不了
google一下,原来其为 SPHERE文件格式
整个语音库有6300个文件,如何全部转换为普通的wav文件?
step1 遍历整个文件夹,把所有wav文件全找出来 find_wav.m
function [ wav_files ] = find_wav( path )
%FIND_WAV, find all wav file recursively
wav_files = [];
if(isdir(path) == 0)
return;
end
path_files = dir(path);
fileNum = length(path_files);
for k= 3:fileNum
file = [path,'\', path_files(k).name];
if (path_files(k).isdir == 1)
ret = find_wav(file);
if(isempty(ret) ~= 1)
if(isempty(wav_files))
wav_files = char(ret);
else
wav_files = char(wav_files, ret);
end
end
elseif strfind(path_files(k).name, '.wav')
if(isempty(wav_files))
wav_files = char(file);
else
wav_files = char(wav_files, file);
end
end
end
end
step2 文件转换conver_wav.m
%SPHERE 文件转换为wav文件
clear all;
fs = 16000;
files = find_wav('.');
for fileIdx = 1:length(files)
file = files(fileIdx,:);
fileID = fopen(file);
%判断文件头,防止误操作
head = fread(fileID, 1024, 'char*1');
headStr = sprintf('%s',head(1:7));
if(~strcmp(headStr,'NIST_1A'))
fclose(fileID);
continue;
end
frewind(fileID);
allData = fread(fileID, inf, 'short');
fclose(fileID);
delete(file);
wavwrite(allData(513:end)./32768, fs, file); %SPHERE 文件头1024字节
end
step3 检查 check_wav.m
clear all;
files = find_wav('.');
for fileIdx = 1:length(files)
file = files(fileIdx,:);
[y, fs, nbits] = wavread(file);%不是wav文件就会报错
if(fs~=16000)
fprintf('%s: fs~=16000\n', file);
end
if(nbits ~= 16)
fprintf('%s: nbits ~= 16\n', file);
end
end
大功告成
联系客服