Recent

Author Topic: How to use text-to-speech with lazarus  (Read 19117 times)

ari

  • New member
  • *
  • Posts: 8
How to use text-to-speech with lazarus
« on: March 28, 2007, 03:55:12 pm »
Hello,

My question is:

   How can I use the text-to-speech technology with Lazarus?

   I realized that with DELPHI + SAPI5 before , but I have no idea
   how to do that with lazarus!    

   Thanks    :roll:

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: How to use text-to-speech with lazarus
« Reply #1 on: March 28, 2007, 06:41:29 pm »
I know a good example of speech on Lazarus, but in portuguese. http://acbr.sourceforge.net/wiki/index.php/P%E1gina_principal , ACBr_0.8.5b.zip, FalaTeste.lpi.

ari

  • New member
  • *
  • Posts: 8
RE: How to use text-to-speech with lazarus
« Reply #2 on: March 29, 2007, 08:23:18 am »
Hello Antonio,

thank you for your reply, I have downloaded it and I looked for...

There is really something with speech but I think they create the
voices with .wav files, and that is not the text-to-speech what I mean.


Thanks and greeting  :P

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: How to use text-to-speech with lazarus
« Reply #3 on: March 29, 2007, 04:06:43 pm »
Quote from: "ari"
There is really something with speech but I think they create the
voices with .wav files, and that is not the text-to-speech what I mean.


What platform are you interested in?

On Mac OS X, this is pretty easy to do. For example, here is an AppleScript example that "speaks" the version of OS X:

tell application "Finder"
  set system_version to (get the version) as number
  do shell script "say 'This is Mac OSX'" & system_version
  return system_version
end tell

This example is from

http://www.kernelthread.com/mac/osx/programming.htmll

You can run AppleScript like this using the Lazarus shell function.

Thanks.

ari

  • New member
  • *
  • Posts: 8
RE: Re: RE: How to use text-to-speech with lazarus
« Reply #4 on: March 29, 2007, 07:37:17 pm »
Hello Phil,

My platform is windows xp.

I have already realized a program and it works very well.
My program can read texts and can speak they in english (Speech Synthesis), even it can understand english words which it hears from comp.microphone.(Speech Recognition).

Like this example:

http://www.blong.com/Conferences/DCon2002/Speech/SAPI51/SAPI51.htm

Now I want do all these with lazarus + firebird-db(embeded). I am new with lazarus and I don't know how to access to "Microsoft Speech Object Library (Version 5.1)" from lazarus......to use all components for this work....

Thanks. :)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: RE: How to use text-to-speech with lazarus
« Reply #5 on: March 29, 2007, 08:14:27 pm »
Quote from: "ari"
I am new with lazarus and I don't know how to access to "Microsoft Speech Object Library (Version 5.1)" from lazarus......to use all components for this work....


How are you accessing the Microsoft speech library now?

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Re: RE: Re: RE: How to use text-to-speech with lazarus
« Reply #6 on: March 30, 2007, 08:29:55 pm »
Quote from: "ari"
thank you for your reply, I have downloaded it and I looked for...

There is really something with speech but I think they create the
voices with .wav files, and that is not the text-to-speech what I mean.

This question confused me. As text-to-speech is available only on english, german and french... Sorry.

ari

  • New member
  • *
  • Posts: 8
RE: Re: RE: Re: RE: How to use text-to-speech with lazarus
« Reply #7 on: April 04, 2007, 07:43:03 am »
Here is a very simple example of TTS, which runs  in Delphi but doesn't work in Lazarus.
Can you tell me please what must I do, so it runs also with Lazarus?

Thanks

***********************************************************************
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
    SpVoice: Variant;
begin
    SpVoice := CreateOleObject('SAPI.SpVoice');
    SpVoice.Speak('Hallo World', 0);
end;

end.
*************************************************************** :shock:

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Re: RE: Re: RE: How to use text-to-speech with lazar
« Reply #8 on: April 04, 2007, 07:21:00 pm »
Quote from: "ari"
Here is a very simple example of TTS, which runs  in Delphi but doesn't work in Lazarus.
Can you tell me please what must I do, so it runs also with Lazarus?

:


I assume you haven't gotten it to compile, much less run. There are commands on the Lazarus Tools menu for converting Delphi source to Lazarus. However, for a simple example like this, just create a new app in Lazarus, add a button, and paste your event handler's code into the button's event handler. You'll also need to add ComObj and Variants to uses.

That should compile, but I don't if it will run. You're using the Automation interface to run the speech library. This is a Windows-only technology and Free Pascal doesn't fully support it yet. However, if the app runs but crashes or displays an error message, you can report it as an FPC bug with Bugtracker (see Laz Web site).

Question: Why do you want to do this in Lazarus when the result will be only be useable on Windows? Why not just continue using Delphi since it's a Windows-only app you're developing?

ari

  • New member
  • *
  • Posts: 8
RE: Re: RE: Re: RE: Re: RE: How to use text-to-speech with l
« Reply #9 on: April 04, 2007, 10:49:09 pm »
Hello Phil,

Thank you for your reply,

I got the message, and I see that I must wait new versions of Lazarus.
I am sure the Lazarus develop team will solve all these problems soon.
Delphi is good I think and hope Lazarus will better!


  Thanks and greetings :D

jw

  • Full Member
  • ***
  • Posts: 126
Re: How to use text-to-speech with lazarus
« Reply #10 on: September 21, 2010, 02:56:34 am »
This is a really old post but the suggestion given do currently work in lazarus so I'm adding to the post to let others know cause I searched and searched and re-read this post a lot of times thinking this wouldn't work.

below is code that is modified as phil suggeted and it talks on my computer.

Windows xp sapi 5.1 development sdk
I don't think you need the development sdk it should use the default sam voice


Code: [Select]

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, ComObj, Variants;

type

  { TForm1 }

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
var
    SpVoice: Variant;
begin
    SpVoice := CreateOleObject('SAPI.SpVoice');
    SpVoice.Speak('Hallo World', 0);
    halt(1);
end;


initialization
  {$I unit1.lrs}

end.
                                              




if anyone knows how to get it to accept commnds via voice recognition please post that as well thanks.
« Last Edit: September 21, 2010, 03:06:33 am by jw »

 

TinyPortal © 2005-2018