17-10-12, 01:45 PM
كاتب الموضوع : AhmedEssawy
منقول من هنا :http://www.bytemycode.com/snippets/snippet/646/
كود :
Option Explicit
[COLOR=#ff0000]'By Timbo
Const SVSFlagsAsync = 1
const SVSFPurgeBeforeSpeak = 2
Dim Speech
Dim FSO
CreateObjects
Main
DestroyObjects
Quit
Sub Main
Dim sText
sText = InputBox("Enter the text you want the computer to say", "Text2Speech")
sText = Trim(sText)
If sText <> "" Then
SpeakText sText
End If
End Sub
Sub SpeakText(sText)
On Error Resume Next
Speech.Speak sText, SVSFlagsAsync + SVSFPurgeBeforeSpeak
Do
Sleep 100
Loop Until Speech.WaitUntilDone(10)
End Sub
Sub StopSpeaking()
On Error Resume Next
Speech.Speak vbNullString, SVSFPurgeBeforeSpeak
Set Speech = Nothing
End Sub
Sub CreateObjects
Set Speech = CreateObject("SAPI.SpVoice")
Set FSO = CreateObject("Scripting.FileSystemObject")
End Sub
Sub DestroyObjects
Set Speech = Nothing
Set FSO = Nothing
End Sub
Sub Sleep(nTimeout)
WScript.Sleep nTimeout
End Sub
Sub Quit
WScript.Quit
End Sub[/COLOR]