Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 5.00 KB | None | 0 0
  1.  
  2.  
  3. ; #FUNCTION# ====================================================================================================================
  4. ; Name...........: _StartTTS
  5. ; Description ...: Creates a object to be used with Text-to-Speak Functions.
  6. ; Syntax.........: _StartTTS()
  7. ; Parameters ....:
  8. ; Return values .: Success - Returns a object
  9. ; Author ........: bchris01
  10.  
  11. ; Example .......: Yes
  12. ; ===============================================================================================================================
  13. Func _StartTTS()
  14.     Return ObjCreate("SAPI.SpVoice")
  15. EndFunc   ;==>_StartTTS
  16.  
  17. ; #FUNCTION# ====================================================================================================================
  18. ; Name...........: _SetRate
  19. ; Description ...: Sets the rendering rate of the voice. (How fast the voice talks.)
  20. ; Syntax.........: _SetRate(ByRef $Object, $iRate)
  21. ; Parameters ....: $Object        - Object returned from _StartTTS().
  22. ;                  $iRate         - Value specifying the speaking rate of the voice. Supported values range from -10 to 10
  23. ; Return values .:  None
  24. ; Author ........: bchris01
  25. ; Example .......: Yes
  26. ; ===============================================================================================================================
  27. Func _SetRate(ByRef $Object, $iRate); Rates can be from -10 to 10
  28.     $Object.Rate = $iRate
  29. EndFunc   ;==>_SetRate
  30.  
  31. ; #FUNCTION# ====================================================================================================================
  32. ; Name...........: _SetVolume
  33. ; Description ...: Sets the volume of the voice.
  34. ; Syntax.........: _SetVolume(ByRef $Object, $iVolume)
  35. ; Parameters ....: $Object        - Object returned from _StartTTS().
  36. ;                  $iVolume       - Value specifying the volume of the voice. Supported values range from 0-100. Default = 100
  37. ; Return values .:  None
  38. ; Author ........: bchris01
  39. ; Example .......: Yes
  40. ; ===============================================================================================================================
  41. Func _SetVolume(ByRef $Object, $iVolume);Volume
  42.     $Object.Volume = $iVolume
  43. EndFunc   ;==>_SetVolume
  44.  
  45. ; #FUNCTION# ====================================================================================================================
  46. ; Name...........: _SetVoice
  47. ; Description ...: Sets the identity of the voice used for text synthesis.
  48. ; Syntax.........: _SetVoice(ByRef $Object, $sVoiceName)
  49. ; Parameters ....: $Object        - Object returned from _StartTTS().
  50. ;                  $sVoiceName    - String matching one of the voices installed.
  51. ; Return values .:  Success - Sets object to voice.
  52. ;                   Failure - Sets @error to 1
  53. ; Author ........: bchris01
  54. ; Example .......: Yes
  55. ; ===============================================================================================================================
  56. Func _SetVoice(ByRef $Object, $sVoiceName)
  57.     Local $VoiceNames, $VoiceGroup = $Object.GetVoices
  58.     For $VoiceNames In $VoiceGroup
  59.         If $VoiceNames.GetDescription() = $sVoiceName Then
  60.             $Object.Voice = $VoiceNames
  61.             Return
  62.         EndIf
  63.     Next
  64.     Return SetError(1)
  65. EndFunc   ;==>_SetVoice
  66.  
  67. ; #FUNCTION# ====================================================================================================================
  68. ; Name...........: _GetVoices
  69. ; Description ...: Retrives the currently installed voice identitys.
  70. ; Syntax.........: _GetVoices(ByRef $Object[, $Return = True])
  71. ; Parameters ....: $Object        - Object returned from _StartTTS().
  72. ;                  $bReturn       - String of text you want spoken.
  73. ;                  |If $bReturn = True then a 0-based array is returned.
  74. ;                  |If $bReturn = False then a string seperated by delimiter "|" is returned.
  75. ; Return values .:  Success - Returns an array or string containing installed voice identitys.
  76. ; Author ........: bchris01
  77. ; Example .......: Yes
  78. ; ===============================================================================================================================
  79. Func _GetVoices(ByRef $Object, $bReturn = True)
  80.     Local $sVoices, $VoiceGroup = $Object.GetVoices
  81.     For $Voices In $VoiceGroup
  82.         $sVoices &= $Voices.GetDescription() & '|'
  83.     Next
  84.     If $bReturn Then Return StringSplit(StringTrimRight($sVoices, 1), '|', 2)
  85.     Return StringTrimRight($sVoices, 1)
  86. EndFunc   ;==>_GetVoices
  87.  
  88. ; #FUNCTION# ====================================================================================================================
  89. ; Name...........: _Speak
  90. ; Description ...: Speaks the contents of the text string.
  91. ; Syntax.........: _Speak(ByRef $Object, $sText)
  92. ; Parameters ....: $Object        - Object returned from _StartTTS().
  93. ;                  $sText         - String of text you want spoken.
  94. ; Return values .:  Success - Speaks the text.
  95. ; Author ........: bchris01
  96. ; Example .......: Yes
  97. ; ===============================================================================================================================
  98. Func _Speak(ByRef $Object, $sText)
  99.     $Object.Speak($sText)
  100. EndFunc   ;==>_Speak
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement