Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
#Include "SAPI.inc"
%Msg_SAPI_Event = %WM_User + 1
%IDC_Play = 500
%IDC_Resume = 501
%IDC_Pause = 502
%IDC_Stop = 503
Global hDlg As Dword, isPaused As Long
Global psp As ISPVoice, SpeakText$$, StopText$$
Function PBMain() As Long
Dialog Default Font "Tahoma", 12, 1
Dialog New Pixels, 0, "Speak Test",300,300,250,175, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Play,"Play", 75,10,100,25
Control Add Button, hDlg, %IDC_Pause,"Pause", 75,50,100,25
Control Add Button, hDlg, %IDC_Resume,"Resume", 75,90,100,25
Control Add Button, hDlg, %IDC_Stop,"Stop", 75,130,100,25
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
SpeakText$$ = Repeat$(10,"Tennis every day helps you get a great tan!")
StopText$$ = ""
'initialize SAPI
pSp = NewCom "SAPI.SpVoice"
pSp.SetInterest(SPFEI(%SPEI_WORD_BOUNDARY) Or SPFEI(%SPEI_END_INPUT_STREAM), SPFEI(%SPEI_WORD_BOUNDARY) Or SPFEI(%SPEI_END_INPUT_STREAM))
pSp.SetNotifyWindowMessage(hDlg, %MSG_SAPI_EVENT, 0, 0)
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Play :
If isPaused Then
isPaused = 0
psp.Resume 'Resume
pSp.Speak(ByVal StrPtr(StopText$$), %SVSFPurgeBeforeSpeak, ByVal %NULL) 'Stop
End If
pSp.Speak(ByVal StrPtr(SpeakText$$), %SPF_Async, ByVal %Null)
Case %IDC_Pause
If isPaused = 0 Then isPaused = 1 : pSp.pause
Case %IDC_Resume
psp.resume
Case %IDC_Stop
If isPaused Then isPaused = 0 : psp.Resume
pSp.Speak(ByVal StrPtr(StopText$$), %SVSFPurgeBeforeSpeak, ByVal %NULL)
End Select
End Select
End Function
http://www.garybeene.com/sw/gbsnippets.htm