[fpc-pascal] TProcess with festival

Seth Grover sethdgrover at gmail.com
Fri May 15 20:48:51 CEST 2009


Maybe I'm just dumb, but I cannot figure out why this isn't working.

I wanted to write a simple program which uses TProcess to send input
to festival (the text-to-speech engine). On the command line I can do
something simple like this:
   echo hello | /usr/bin/festival --tts --pipe
and festival will say "hello". Pretty easy...

So why won't this work?

program talkie;

{$mode objfpc}{$H+}

uses
  Classes, SysUtils, Process;

var
  festival : TProcess;
  line : string;
begin
  try
    festival := TProcess.Create(nil);
    try
      festival.Options := [poUsePipes, poStderrToOutput, poNoConsole,
poDefaultErrorMode];
      festival.CommandLine := '/usr/bin/festival --pipe --tts';
      line := 'hello'
      festival.Execute;
      festival.Input.WriteBuffer(line[1], length(line));
    finally
      festival.Terminate(0);
      FreeAndNil(festival);
    end;
  except
    on E : Exception do begin
      writeln('Exception: ' + E.Message);
    end;
  end;
end.

I've googled TProcess for about 2 hours and I'm not seeing what I'm
missing. Can someone smarter than me please illuminate me?

Thanks,

Seth


--
This email is fiction. Any resemblance to actual events
or persons living or dead is purely coincidental.

Seth Grover
sethdgrover[at]gmail[dot]com



More information about the fpc-pascal mailing list