Assistant package question

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

Assistant package question

Postby sfpx » June 20th, 2006, 1:26 am

First, thank you for this excellent component !

Now, here is my stupid question.

How do we make the assistant to speak a sequence of strings ?
Let's say I want the assistant to say "Hello" then pause for about 2 seconds and then say "Welcome to my program".

I tried many things but couldn't get it to work. I always only see the last sentence.
sfpx
Member
Member
 
Posts: 4
Joined: June 20th, 2006, 1:20 am

Postby Kambiz » June 21st, 2006, 6:05 pm

The office assistant package is not speech enabled. You have to use a third-party component for this purpose.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby sfpx » June 21st, 2006, 8:11 pm

Sorry I explained my problem badly.
I meant to "speak" with the balloon text.
One balloon saying "Hello" then 2 seconds later saying"welcome "
sfpx
Member
Member
 
Posts: 4
Joined: June 20th, 2006, 1:20 am

Postby Kambiz » June 21st, 2006, 10:40 pm

It was my fault not reading the question carefully, sorry.

I hope the following piece of code helps.

Code: Select all
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, oaTypes, StdCtrls, oaAssist;

const
  WM_SAYNEXTPART = WM_USER + 1;

type
  TForm1 = class(TForm)
    Assistant1: TAssistant;
    Memo1: TMemo;
    Button1: TButton;
    procedure Assistant1BalloonHide(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    SpeakIndex: Integer;
    procedure WMSayNextPaty(var Msg: TMessage); message WM_SAYNEXTPART;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Assistant1BalloonHide(Sender: TObject);
begin
  PostMessage(Handle, WM_SAYNEXTPART, 0, 0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  SpeakIndex := -1;
  PostMessage(Handle, WM_SAYNEXTPART, 0, 0);
end;

procedure TForm1.WMSayNextPaty(var Msg: TMessage);
begin
  Inc(SpeakIndex);
  if SpeakIndex < Memo1.Lines.Count then
    Assistant1.Speak(Memo1.Lines[SpeakIndex], 2000);
end;

end.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby sfpx » June 22nd, 2006, 6:06 pm

Thanks for the code but unfortunately it doesn't work exactly like I want.

Of course if I click on the button that executes
PostMessage(Handle, WM_SAYNEXTPART, 0, 0);
many times I'll get a sequence of balloons.

But I want the sequence to be launched in a procedure. Your code works because the user ends up doing the job of "pausing" between the messages.

Let's say for example that in the button onclick event we have


Code: Select all
procedure TForm1.Assistant1BalloonHide(Sender: TObject);
var i:integer;
begin
  for i:= 0 to memo1.Lines.Count-1 do PostMessage(Handle, WM_SAYNEXTPART, 0, 0);

end;


Then only the last line will be displayed
sfpx
Member
Member
 
Posts: 4
Joined: June 20th, 2006, 1:20 am

Postby Kambiz » June 22nd, 2006, 8:18 pm

What I wrote, was somthing as a hint.

Of course you might not use a for-loop to post several messages on the message queue. You should use a timer and control the timer using the OnBalloonHide event.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby sfpx » June 23rd, 2006, 1:06 am

I'm just an idiot ;)
I badly implemented the code you gave me.
It actually works.

Thank you again
sfpx
Member
Member
 
Posts: 4
Joined: June 20th, 2006, 1:20 am


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest

cron