Sign in Join

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

Mailing lists / fpc-pascal / 2008-05

Playing with SpVoice (ole object)

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Joao Morais

Hello,

the following code:

{$mode objfpc}{$H+}
uses
   comobj;
var
   vsound: olevariant;
   s: string;
begin
   vsound := createoleobject('SAPI.SpVoice');
   writeln('playing using literal');
   vsound.speak('hello world');
   writeln('ok (press enter)');
   readln;
   writeln('now playing using a string var');
   s := 'hello world';
   vsound.speak(s);
   writeln('ok (press enter)');
   readln;
end.

speaks using a literal but says randomic words (sometimes says nothing) using a variable. Is there something that I am missing?

Thanks.

Unknown author
to Joao Morais
Joao Morais wrote 5 lines
s := 'hello world'; vsound.speak(s); speaks using a literal but says randomic words (sometimes says nothing) using a variable. Is there something that I am missing?

You should use a variable of type WideString:
VAR

  S: WideString;

....
And all will be good
-------------
Best regards
Boriss

Marco van de Voort
to Joao Morais: the following code: {$mode objfpc}{$H+} uses comobj; var vsound: olevariant; s: string;…
Show quoted text 22 lines
{$mode objfpc}{$H+} uses comobj; var vsound: olevariant; s: string; begin vsound := createoleobject('SAPI.SpVoice'); writeln('playing using literal'); vsound.speak('hello world'); writeln('ok (press enter)'); readln; writeln('now playing using a string var'); s := 'hello world'; vsound.speak(s); writeln('ok (press enter)'); readln; end. speaks using a literal but says randomic words (sometimes says nothing) using a variable. Is there something that I am missing?

I've been thinking of adding some interesting code snippets to the examples of the winunits package (to which comobj belongs). Do you mind if I add this to SVN ? (lGPL licensed)

Joao Morais
to Marco van de Voort
Marco van de Voort wrote 22 lines
> {$mode objfpc}{$H+} > uses > comobj; > var > vsound: olevariant; > s: string; > begin > vsound := createoleobject('SAPI.SpVoice'); > writeln('playing using literal'); > vsound.speak('hello world'); > writeln('ok (press enter)'); > readln; > writeln('now playing using a string var'); > s := 'hello world'; > vsound.speak(s); > writeln('ok (press enter)'); > readln; > end. I've been thinking of adding some interesting code snippets to the examples of the winunits package (to which comobj belongs). Do you mind if I add this to SVN ? (lGPL licensed)

Of course not. go ahead.

Joao Morais
to Unknown author: You should use a variable of type WideString: VAR S: WideString; .... And all will be good
Show quoted text 12 lines
Joao Morais wrote: > s := 'hello world'; > vsound.speak(s); > speaks using a literal but says randomic words (sometimes says > nothing) using a variable. Is there something that I am missing? You should use a variable of type WideString: VAR S: WideString; .... And all will be good

Discovered this issue some minutes ago =) Thank you!