[fpc-pascal] TProcess with festival
Vincent Snijders
vsnijders at vodafonevast.nl
Fri May 15 20:59:41 CEST 2009
Seth Grover schreef:
> 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'
Maybe:
line := 'hello' + LineEnding;
> 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.
>
Vincent
More information about the fpc-pascal
mailing list