Mega Code Archive

 
Categories / Delphi / Examples
 

Let your messages speaks

Title: Let your messages speaks. Question: Make your application more fun to users by displaying messages with voices. Answer: Very simple. USES ComObj; .......................................................................... .......................................................................... procedure Speak(const sText : String; bWithVoice : Boolean = True); const SVSFDefault = $00000000; SVSFlagsAsync = $00000001; var oVoice: OLEVariant; begin if bWithVoice then begin oVoice := CreateOLEObject('SAPI.SpVoice'); oVoice.Speak(sText, SVSFlagsAsync); end; Showmessage(sText); oVoice := Unassigned; end; Examples: //With voice. Speak('Hello people'); //Without voice. Speak('Hello people', False);