Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-05

TProcess with festival

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Seth Grover

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

Reply by email

Vincent Snijders
to Seth Grover
Seth Grover wrote 28 lines
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;
Show quoted text 13 lines
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

Reply by email

Seth Grover
to Seth Grover: Maybe I'm just dumb, but I cannot figure out why this isn't working. I wanted to write a…

Okay, I figured it out...

Turns out I was using festival wrong, though I'm still not sure how. It wasn't a problem with how I was using TProcess.

If I run festival like this (not using --tts mode)

    FestivalProc.CommandLine := '/usr/bin/festival --pipe';

And pass "SayText" commands like this, rather than just passing it the text I want read:

    line := '(SayText "hello")';
    FestivalProc.Input.WriteBuffer(line[1], length(line));

It works fine.

Thanks for your help!

-SG

This email is fiction. Any resemblance to actual events or persons living or dead is purely coincidental. Seth Grover sethdgrover[at]gmail[dot]com On Fri, May 15, 2009 at 12:48 PM, Seth Grover wrote: > 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 >

Reply by email