{--------------------------------------------------------------------------

                     HighSpeed Pascal for the Amiga

                           SIMPLE SPEECH DEMO

                  Programmed by Martin Eskildsen 1991

                  Copyright (c) 1991 by D-House I ApS
                         All rights reserved


  Version : Date (dd.mm.yy) : Comment
  -----------------------------------
    1.00 : 06.11.91 : First version

--------------------------------------------------------------------------}
program SimpleSpeech;

uses Init, Narrator, Speech;

const
  Hello = 'Hello World!';
  N     = 6;

procedure Pause;
begin
  Delay(1000)
end;

procedure SayIt(s : string);
begin
  Inform(s);
  Say(s)
end;

procedure SayItAndWait(s : string);
begin
  SayIt(s);
  Pause
end;

procedure Rates;
var i : 1..N;
begin
  for i := 1 to N do begin
    SetRate( (Narrator.MAXRATE - Narrator.MINRATE) div N * i);
    Say(Hello)
  end;
  Pause
end;

procedure Frequency;
var i : 1..N;
begin
  for i := 1 to N do begin
    SetFrequency( (Narrator.MAXFREQ - Narrator.MINFREQ) div N * i);
    Say(Hello)
  end;
  Pause
end;

procedure Pitch;
var i : 1..N;
begin
  for i := 1 to N do begin
    SetPitch( (Narrator.MAXPITCH - Narrator.MINPITCH) div N * i);
    Say(Hello)
  end;
  Pause
end;

begin
  if PrepareEnvironment('Simple Speech') then begin

    Message('Let''s initiate the Translator lib and Narrator device');
    if Panic(not OpenSpeech, 'Could not initiate speech properly') then begin
      CloseDown;
      Exit
    end;

    SetVolume( (Narrator.MAXVOL - Narrator.MINVOL) div 2 );

    SayItAndWait('Hello, I''m an Amiga demo!');

    SayIt       ('We are now using the default values.');
    SayItAndWait('Why don''t we change them?');

    SetSex(male);    SayIt       ('This is a male voice');
    SetSex(female);  SayItAndWait('And this is a female voice');
    DefaultParameters([SexParam]);

    SayItAndWait('Let''s play with the word rate. The words are "' + Hello + '"');
    Rates;
    DefaultParameters([RateParam]);

    SayItAndWait('And the frequency.');
    Frequency;
    DefaultParameters([FreqParam]);

    SayItAndWait('And the pitch.');
    Pitch;
    DefaultParameters([PitchParam]);

    SetVolume(Narrator.MINVOL + 10);    SayIt       ('This is a whisper');
    SetVolume(Narrator.MAXVOL);         SayItAndWait('AND THIS IS LOUD!');

    SetVolume( (Narrator.MAXVOL - Narrator.MINVOL) div 2 );

    SayIt('That was all I had to say!');

    CloseSpeech;
    CloseDown
  end
end.
