F
fuzengbin
Unregistered / Unconfirmed
GUEST, unregistred user!
我的两段代码,第一段通过SaveDialog可以成功地创建一个Wav格式的文件,并把文字转成语音保存。而第二段代码,不想使用SaveDialog对话框,直接就生成一个Wav文件,却不行。请高手回答该怎样解决第二段代码的问题。(在线等待.....)
第一段:
if SaveDialog1.Execute then
begin
if not (DataSource1.DataSet.State in [dsedit]) then
DataSource1.DataSet.Edit;
DataSource1.DataSet.FieldByName('wavpath').AsString := SaveDialog1.FileName;
DataSource1.DataSet.Post;
try
SpFileStream1.Open(SaveDialog1.FileName,SSFMCreateForWrite,false);
SpVoice1.AudioOutputStream := SpFileStream1.DefaultInterface;
SpVoice1.Speak(DBRichEdit1.Text,SVSFlagsAsync);
SpVoice1.WaitUntilDone(SpVoice1.SynchronousSpeakTimeout);
SpFileStream1.Close;
except
MessageBox(handle,'你没有安装微软Speech SDK,该功能无法正常使用!','系统提示',MB_OK+MB_ICONINFORMATION);
end;
end;
第二段:
WavName:= ExtractFilePath(Application.ExeName)+'wav/'+DataSource1.DataSet.FieldByName('kssj').AsString+'.wav';
if not (DataSource1.DataSet.State in [dsedit]) then
DataSource1.DataSet.Edit;
DataSource1.DataSet.FieldByName('wavpath').AsString := WavName;
DataSource1.DataSet.Post;
CreateDirectory(PChar(ExtractFilePath(Application.ExeName)+'/wav'),nil);
CreateFile(PChar(WavName), GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
try
SpFileStream1.Open(WavName,SSFMCreateForWrite,false);
SpVoice1.AudioOutputStream := SpFileStream1.DefaultInterface;
SpVoice1.Speak(DBRichEdit1.Text,SVSFlagsAsync);
SpVoice1.WaitUntilDone(SpVoice1.SynchronousSpeakTimeout);
SpFileStream1.Close;
except
MessageBox(handle,'你没有安装微软Speech SDK,该功能无法正常使用!','系统提示',MB_OK+MB_ICONINFORMATION);
end;
第一段:
if SaveDialog1.Execute then
begin
if not (DataSource1.DataSet.State in [dsedit]) then
DataSource1.DataSet.Edit;
DataSource1.DataSet.FieldByName('wavpath').AsString := SaveDialog1.FileName;
DataSource1.DataSet.Post;
try
SpFileStream1.Open(SaveDialog1.FileName,SSFMCreateForWrite,false);
SpVoice1.AudioOutputStream := SpFileStream1.DefaultInterface;
SpVoice1.Speak(DBRichEdit1.Text,SVSFlagsAsync);
SpVoice1.WaitUntilDone(SpVoice1.SynchronousSpeakTimeout);
SpFileStream1.Close;
except
MessageBox(handle,'你没有安装微软Speech SDK,该功能无法正常使用!','系统提示',MB_OK+MB_ICONINFORMATION);
end;
end;
第二段:
WavName:= ExtractFilePath(Application.ExeName)+'wav/'+DataSource1.DataSet.FieldByName('kssj').AsString+'.wav';
if not (DataSource1.DataSet.State in [dsedit]) then
DataSource1.DataSet.Edit;
DataSource1.DataSet.FieldByName('wavpath').AsString := WavName;
DataSource1.DataSet.Post;
CreateDirectory(PChar(ExtractFilePath(Application.ExeName)+'/wav'),nil);
CreateFile(PChar(WavName), GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
try
SpFileStream1.Open(WavName,SSFMCreateForWrite,false);
SpVoice1.AudioOutputStream := SpFileStream1.DefaultInterface;
SpVoice1.Speak(DBRichEdit1.Text,SVSFlagsAsync);
SpVoice1.WaitUntilDone(SpVoice1.SynchronousSpeakTimeout);
SpFileStream1.Close;
except
MessageBox(handle,'你没有安装微软Speech SDK,该功能无法正常使用!','系统提示',MB_OK+MB_ICONINFORMATION);
end;