Hi!

Hi! 
just for a joke i made a "text to speech"  in delphi VCL with google translate services.
it's very simple, but it works fine ( for now ... maybe in the future if google changes something ...) and in all languages.  i tested it in italian.

you can use it in async mode , and in this case you must call close method manually, or in sync mod.
to change language, change link const.


uses MMSystem,HTTPApp ; 

const
  link_parla : string = 'http://translate.google.com/translate_tts?tl=it&q=%s&.mp3' ;


procedure talk_close_if_async ;
begin
  mciSendString('close MP3', 0,0,0);
end;

procedure talk( sentence:string ; async : boolean = true  ) ;
 var link : string ;
begin
  link := Format(link_parla,[HTTPEncode( sentence )]);
  mciSendString('close MP3', 0,0,0);
  mciSendString(PChar('open "' + link +  '" alias MP3'), NIL, 0, 0);
  if async then  mciSendString('play MP3 ', NIL, 0, 0)
  else begin
      mciSendString('play MP3 wait', NIL, 0, 0) ;
     mciSendString('close MP3', 0,0,0);
  end;
end;

:)
I share this with you, and , btw,  i ask if there's other  free way to do the same thing  :)

Comments

  1. The free Microsoft text-to-speech library also works with Delphi.  I have used that a lot in life-safety apps for firemen and HAZMAT workers - written in Delphi.  "Warning! Carbon Monoxide level is high!"

    ReplyDelete
  2. yes, but it's only in  English, ins't it?

    ReplyDelete
  3. I think you can add speech files for languages other than English.  IIRC, most of the non-English ones you have to pay for, but I didn't look that close since all I needed for my project was English.  I used a female voice along with a male voice to break up monotony (both free).  I recall some British speech files were available that pronounce things the UK way.

    ReplyDelete
  4. The upside of using a text-to-speech engine is that you don't need a high-bandwidth Internet connection.  My network speed was 960 Characters Per Second over a  narrow band VHF radio link, so "surfing the net" was not an option :-)

    ReplyDelete

Post a Comment