M
mike1031
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB,DBTables,mmsystem, Menus, DBCtrls,
Mask, ExtCtrls, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
procedure Sounding(sText:String;iNum:integer);
//sText:要播放的文本,iNum:该文本要播放的次数;
procedure GetSound(sText:String);
//获得声音,参数:stext:文本
var i:integer;
br:string;
implementation
{$R *.dfm}
procedure Sounding(sText:String;iNum:integer);
//sText:要播放的文本,iNum:该文本要播放的次数;
var i:integer;
//如:001号请到002号房间去
begin
for i:=0 to iNum-1do
GetSound(sText);
end;
procedure GetSound(sText:String);
//获得声音,参数:stext:文本
var sStr,s:string;
bChina:Boolean;
procedure Sing(sStr:String);
//产生声音
var sWav:String;
begin
sWav:='mus/wav_'+sStr+'.wav';
if sStr='' then
exit;
try
if ((sStr=' ') or (sStr=',') or (sStr='.') or (sStr=';') or (sStr='!')) then
sndPlaySound('wav_.wav',SND_NODEFAULT) //停止一会
else
begin
sndPlaySound(PChar(sWav),SND_NODEFAULT)
end;
except
Showmessage('语音库中没有下列文件:wav_'+sStr+'.wav');
end;
end;
begin
sStr:=sText;
bChina:=False;
while length(sStr)>0do
//判断文本是否结束
begin
s:='';
if ((Copy(sStr,1,1)='<') or (bChina=True)) and (Copy(sStr,1,1)<>'>') then
//判断标识符
begin
bChina:=True;
if Copy(sStr,1,1)='<' then
sStr:=Copy(sStr,2,length(sStr));
s:=Copy(sStr,1,2);
sStr:=Copy(sStr,3,length(sStr));
end
else
if (Copy(sStr,1,1)='>') or (bChina=False) then
//判断标识符
begin
bChina:=False;
if Copy(sStr,1,1)='>' then
sStr:=Copy(sStr,2,length(sStr));
if Copy(sStr,1,1)<>'<' then
begin
s:=Copy(sStr,1,1);
sStr:=Copy(sStr,2,length(sStr));
end;
end;
Sing(s);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Sounding('337<号到>8<号房>',1);
//sText:要播放的文本,iNum:该文本要播放的次数;
end
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB,DBTables,mmsystem, Menus, DBCtrls,
Mask, ExtCtrls, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
procedure Sounding(sText:String;iNum:integer);
//sText:要播放的文本,iNum:该文本要播放的次数;
procedure GetSound(sText:String);
//获得声音,参数:stext:文本
var i:integer;
br:string;
implementation
{$R *.dfm}
procedure Sounding(sText:String;iNum:integer);
//sText:要播放的文本,iNum:该文本要播放的次数;
var i:integer;
//如:001号请到002号房间去
begin
for i:=0 to iNum-1do
GetSound(sText);
end;
procedure GetSound(sText:String);
//获得声音,参数:stext:文本
var sStr,s:string;
bChina:Boolean;
procedure Sing(sStr:String);
//产生声音
var sWav:String;
begin
sWav:='mus/wav_'+sStr+'.wav';
if sStr='' then
exit;
try
if ((sStr=' ') or (sStr=',') or (sStr='.') or (sStr=';') or (sStr='!')) then
sndPlaySound('wav_.wav',SND_NODEFAULT) //停止一会
else
begin
sndPlaySound(PChar(sWav),SND_NODEFAULT)
end;
except
Showmessage('语音库中没有下列文件:wav_'+sStr+'.wav');
end;
end;
begin
sStr:=sText;
bChina:=False;
while length(sStr)>0do
//判断文本是否结束
begin
s:='';
if ((Copy(sStr,1,1)='<') or (bChina=True)) and (Copy(sStr,1,1)<>'>') then
//判断标识符
begin
bChina:=True;
if Copy(sStr,1,1)='<' then
sStr:=Copy(sStr,2,length(sStr));
s:=Copy(sStr,1,2);
sStr:=Copy(sStr,3,length(sStr));
end
else
if (Copy(sStr,1,1)='>') or (bChina=False) then
//判断标识符
begin
bChina:=False;
if Copy(sStr,1,1)='>' then
sStr:=Copy(sStr,2,length(sStr));
if Copy(sStr,1,1)<>'<' then
begin
s:=Copy(sStr,1,1);
sStr:=Copy(sStr,2,length(sStr));
end;
end;
Sing(s);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Sounding('337<号到>8<号房>',1);
//sText:要播放的文本,iNum:该文本要播放的次数;
end
end.