如何实现语音报时?(100分)

  • 主题发起人 主题发起人 MIB
  • 开始时间 开始时间
1、录零到五十九
2、读小时部分,读一个数字
3、读点
4、如果分部分为0则结束,否则执行5
5、读分钟部分;
6、读分
7、如秒为0则不结束,否则读秒部分数字
8、读秒
一个 [0..59]的ARRAY应该解决问题吧:)
或者一个存放wav文件名的stringlist
playsound(stringlist[n])来放声音,呵呵
 
用声卡的效果不会好,用语音卡我到做过
 
我刚学DELPHI没过久,想先实现整点报时能具体指点吗?
 
简单呀,录1-12的声音,1.WAV...,D.WAV为点
timer中判断是否到时间,如果到了,PLAYSOUND相应的WAV然后D.WAV
 
录1,2,3,4,5,6,7,8,9,10,点,两,为一个WAV文件
再用timer中判断是否到时间,如果到了,用MDIAPLAYER控件
播放WAV,给你原程序自己看吧
 
unit maincolock;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, MPlayer, AHMClasses, AHMTTimeTrigger, AHMClasses2,
Buttons, lmdctrl, Lmdclock, lmdclass, lmdformA;
type
TYybs = class(TForm)
MediaPlayer1: TMediaPlayer;
AHMTimeTrigger1: TAHMTimeTrigger;
SpeedButton1: TSpeedButton;
LMDClock1: TLMDClock;
LMDFormShadow1: TLMDFormShadow;
procedure AHMTimeTrigger1Trigger(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
//procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Yybs: TYybs;
procedure Playposmdi(strtp,endp:longint);
procedure baoshi;

implementation

{$R *.DFM}
procedure Playposmdi(strtp,endp:longint);
begin
with yybs.MediaPlayer1 do
begin
startpos:=strtp;
endpos:=endp;
try
wait:=true;
play;
finally
end;
end;
end;
procedure baoshi;
var
baoshi:array[0..14,0..2]of longint;
h,m,se,bse:word;
x1:longint;
begin
baoshi[0,1]:=2100; baoshi[0,2]:=2500
baoshi[1,1]:=2600 baoshi[1,2]:=3000
baoshi[2,1]:=3200 baoshi[2,2]:=3600
baoshi[3,1]:=4000 baoshi[3,2]:=4700
baoshi[4,1]:=4700 baoshi[4,2]:=5200
baoshi[5,1]:=5200 baoshi[5,2]:=5600
baoshi[6,1]:=5900; baoshi[6,2]:=6300
baoshi[7,1]:=6700 baoshi[7,2]:=6990
baoshi[8,1]:=7400 baoshi[8,2]:=7600
baoshi[9,1]:=8007 baoshi[9,2]:=8500
baoshi[10,1]:=8700 baoshi[10,2]:=9000;
baoshi[11,1]:=9300 baoshi[11,2]:=9600
baoshi[13,1]:=9790 baoshi[13,2]:=10400
baoshi[12,1]:=10500 baoshi[12,2]:=10900
baoshi[14,1]:=10999 baoshi[14,2]:=11475

decodeTime(now,h,m,se,bse);
if h>=20 then playposmdi(baoshi[2,1],baoshi[2,2]);
if h>=10 then Playposmdi(baoshi[10,1],baoshi[10,2]);
x1:=h-trunc(h/10)*10;
if x1<>0then
if h<10then playposmdi(baoshi[x1,1],baoshi[x1,2])
else
if x1=2then
playposmdi(baoshi[12,1],baoshi[12,2])
else playposmdi(baoshi[x1,1],baoshi[x1,2]);
x1:=11;
playposmdi(baoshi[x1,1],baoshi[x1,2]);
if m>0 then
begin
x1:=Trunc(m/10);
if x1<>1then
playposmdi(baoshi[x1,1],baoshi[x1,2]);
if x1<>0then
begin
x1:=10;
playposmdi(baoshi[x1,1],baoshi[x1,2]);
end;
x1:=m-trunc(m/10)*10;
if x1<>0then
playposmdi(baoshi[x1,1],baoshi[x1,2]);
x1:=13;
playposmdi(baoshi[x1,1],baoshi[x1,2]);
end
else
begin
x1:=14;
playposmdi(baoshi[x1,1],baoshi[x1,2]);
end;
end;

procedure TYybs.AHMTimeTrigger1Trigger(Sender: TObject);
var
newtime:string;

begin
newtime:=AHMTimeTrigger1.CurrentTime;
if copy(newtime,4,5)='00:00' then
AHMTimeTrigger1.TriggerTime:=AHMTimeTrigger1.CurrentTime;
end;

procedure TYybs.SpeedButton1Click(Sender: TObject);
begin
baoshi;
// Playposmdi(strtoint(Edit1.text),strtoint(Edit2.text));
end;
end.
 
多人接受答案了。
 
后退
顶部