#Include <Array.au3>
#include <GUIConstants.au3>
#include <GuiComboBox.au3>
Global $voicequeue, $In = 3, $bVolume, $bRate, $Text, $Prav, $voice, $Playing = False, $voice = ObjCreate("SAPI.SpVoice")
Global $mfile, $mOpen, $mSave, $mExit, $mView, $mlng, $mlang, $mlrus, $mVosp, $mSpeak, $mPause, $mStop, $mhelp, $mAbout, $V, $S
$Window = GUICreate("Text to Speech", 640, 480, -1, -1)
AdlibRegister("Set", 50)
$mfile = GUICtrlCreateMenu ("Файл")
$mOpen = GUICtrlCreateMenuitem ("Открыть", $mfile)
$mSave = GUICtrlCreateMenuitem ("Сохранить", $mfile)
GUICtrlCreateMenuitem ( "", $mfile)
$mExit = GUICtrlCreateMenuitem ( "Выход", $mfile)
$mVosp = GUICtrlCreateMenu("Воспроизведение")
$mSpeak = GUICtrlCreateMenuitem("Воспроизведение", $mVosp)
$mPause = GUICtrlCreateMenuitem("Пауза", $mVosp)
$mStop = GUICtrlCreateMenuitem("Стоп", $mVosp)
$mhelp = GUICtrlCreateMenu ("Справка")
$mAbout = GUICtrlCreateMenuitem ( "О Программе", $mhelp)
$V = GUICtrlCreateLabel("Громкость", 490, 31, 150, 13)
GUICtrlSetFont(-1, 7.5)
$Vol = GUICtrlCreateLabel("50%", 600, 31, 27, 13)
GUICtrlSetFont(-1, 7.5)
$bVolume = GUICtrlCreateSlider(480, 42, 150, 20, 0x8818)
GUICtrlSetData(-1, 50)
$S = GUICtrlCreateLabel("Скорость", 290, 31, 100, 13)
GUICtrlSetFont(-1, 7.5)
$Ste = GUICtrlCreateLabel("50%", 400, 31, 27, 15)
GUICtrlSetFont(-1, 7.5)
$bRate = GUICtrlCreateSlider(280, 42, 150, 20, 0x8818)
GUICtrlSetData(-1, 50)
GUICtrlCreateLabel("", 0, 29, 645, 1, 0x010)
If @OSVersion = "Win_7" or @OSVersion = "Win_8" Then
$Speak = GUICtrlCreateButton("", 5, 1, 26, 26, 0x0040)
GUICtrlSetImage(-1, "psr.exe", -4, 0)
$Pause = GUICtrlCreateButton("", 30, 1, 26, 26, 0x0040)
GUICtrlSetImage(-1, "psr.exe", -3, 0)
$Stop = GUICtrlCreateButton("", 55, 1, 26, 26, 0x0040)
GUICtrlSetImage(-1, "psr.exe", -6, 0)
Else
$Speak = GUICtrlCreateButton("►", 5, 1, 26, 26)
GUICtrlSetFont(-1, 14)
$Pause = GUICtrlCreateButton("||", 30, 1, 26, 26)
GUICtrlSetFont(-1, 10, 800)
$Stop = GUICtrlCreateButton("▪", 55, 1, 26, 26)
GUICtrlSetFont(-1, 30)
EndIf
$Combo1 = GUICtrlCreateCombo("", 5, 34, 220, 25, 3)
Dim $voic = ObjCreate("SAPI.SpVoice")
Dim $SOTokens = $Voic.GetVoices('', '')
For $Token In $SOTokens
GUICtrlSetData($Combo1, $Token.GetDescription, RegRead(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Speech\Voices", "DefaultTokenId"), ""))
Next
$Text = GUICtrlCreateEdit("", 0, 60, 640, 400, 0x00200000 + 0x1000)
GUICtrlSetState(-1, 256)
GUISetState()
While 1
If UBound($voicequeue) > 0 Then
If $voice.Status.RunningState = 1 Then
$string = _ArrayPop($voicequeue)
EndIf
EndIf
Switch GUIGetMsg()
Case -3, $mExit
Exit
Case $mAbout
Wabout()
Case -8
GUICtrlSetState($Text, 256)
Case $mSpeak, $Speak
If Not $Playing Then
$Playing = True
If Not IsObj($voice) Then Exit MsgBox(0, "TTS Ошибка", "Не удалось запустить SAPI.SpVoice, пожалуйста, убедитесь, что голосовые движки установлены!")
$string = GUICtrlRead($Text)
$voice.Voice = $voice.GetVoices().Item(_GUICtrlComboBox_GetCurSel($Combo1))
$voice.Speak($string, 11)
$Playing = False
Else
$voice.Resume()
$Playing = False
EndIf
Case $mPause, $Pause
$voice.Pause()
$Playing = True
Case $mStop, $Stop
$voice.Speak("", 11)
$Playing = False
Case $mOpen
$File = FileOpenDialog ("Открыть файл", @MyDocumentsDir, "Текст (*.txt)|")
If Not $File Then
Else
GUICtrlSetData($Text, GUICtrlRead($Text) & FileRead($File))
EndIf
Case $mSave
$File = FileSaveDialog ("Сохранение", @MyDocumentsDir, "Текст (*.txt)|")
If Not $File Then
Else
FileOpen($File & ".txt", 2)
FileWrite ($File & ".txt", GUICtrlRead($Text))
EndIf
Case $bVolume
GUICtrlSetData($Vol, GUICtrlRead($bVolume) & "%")
Case $bRate
GUICtrlSetData($Ste, GUICtrlRead($bRate) & "%")
EndSwitch
WEnd
Func Wabout()
$IWin = GUICreate("About", 300, 170, 175, 120, -2138832897, 448, $Window)
GUISetBkColor (0x2F56BE)
$IEx = GUICtrlCreateButton ("OK", 130, 145, 50, 20)
GUICtrlCreateLabel ("Autoit", 10, -5, 200, 70)
GUICtrlSetColor (-1, 0xcfffff)
GUICtrlSetFont (-1, 60, 400, 1, "Giddyup Std")
GUICtrlCreateLabel ("Text to Speech", 12, 67, 200, 50)
GUICtrlSetColor (-1, 0xffffff)
GUICtrlSetFont (-1, 12, 1000)
GUICtrlCreateLabel ("Version: 1.5", 12, 93, 200, 50)
GUICtrlSetColor (-1, 0xffffff)
GUICtrlSetFont (-1, 7.5)
GUICtrlCreateLabel ("© 2013 GUIMish. All Rights Reserved.", 12, 120, 200, 15)
GUICtrlSetColor (-1, 0xffffff)
GUICtrlSetFont (-1, 7)
GUISetState()
Do
Until GUIGetMsg() = $IEx
GUIDelete()
EndFunc
Func Set()
$voice.Volume = GUICtrlRead($bVolume)
$voice.Rate = GUICtrlRead($bRate) - 50
EndFunc