تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تحويل النص إلى كلام باستخدام API من خلال VBScript
#1
كاتب الموضوع : 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]
}}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم