procedure DeleteFileJTVoice(SrcFileName,{源文件名}
SampFileName{样本文件名}: string;SavedFileName{保存的文件名} : string);
var
aStream,bStream,cStream:TMemoryStream;
ap, bp: ^Byte ;
i:integer;
begin
aStream:=TMemoryStream.Create;
bStream:=TMemoryStream.Create;
cStream:=TMemoryStream.Create;
try
aStream.LoadFromFile(SrcFileName);
bStream.LoadFromFile(SampFileName);
if aStream.Size < bStream.Size then
//如果源文件小于样本文件.不需要比较
cStream.CopyFrom(aStream,aStream.Size)
else
begin
//否则比较
cStream.SetSize(aStream.Size);
ap := astream.Memory ;
bp := bstream.Memory ;
for i := 1 to aStream.Sizedo
begin
if ap^ <> bp^ then
begin
cStream.Write(ap^, 1) ;
Inc(ap);
bp := bStream.Memory ;
//复位
end
else
begin
Inc(ap);
Inc(bp);
end;
end;
//因为合成的语音文件.文件尾还有64k杂音要删除
cStream.SetSize(cStream.Size - 64*1024);
end;
cStream.Position := 0;
cStream.SaveToFile(SavedFileName);
finally
aStream.Free;
bStream.Free;
cStream.Free;
end;
end;
关键样本文件要提起正确..不然是比较不出来的.