Here it is then, made all the more difficult by the fact the Speech API (SAPI) isn't present in FreeBasic - I had to do it myself...
Save this one as sapi.bi
NB. This file implements just enough to speak and change the pitch and volume of the voice. I've left loads of it stubbed.
dim IID_ISpVoice as GUID => ( &H6c44df74, &H72b9, &H4992, {&Ha1, &Hec, &Hef, &H99, &H6e, &H04, &H22, &Hd4 })
dim CLSID_SpVoice as GUID => ( &H96749377, &H3391, &H11d2, {&H9e, &He3, &H00, &Hc0, &H4f, &H79, &H73, &H96 })
type ISpVoiceVtbl_ as ISpVoiceVtbl
type ISpVoice
lpVtbl as ISpVoiceVtbl_ ptr
end type
#define SPF_DEFAULT 0
type ISpVoiceVtbl
rem iunknown
QueryInterface as function(byval as ISpVoice ptr, byval as IID ptr, byval as any ptr) as HRESULT
AddRef as function(byval as ISpVoice ptr) as ULONG
Release as function(byval as ISpVoice ptr) as ULONG
rem stubs
SetNotifySink as function() as HRESULT
SetNotifyWindowMessage as function() as HRESULT
SetNotifyCallbackFunction as function() as HRESULT
SetNotifyCallbackInterface as function() as HRESULT
SetNotifyWin32Event as function() as HRESULT
WaitForNotifyEvent as function() as HRESULT
GetNotifyEventHandle as function() as HRESULT
SetInterest as function() as HRESULT
GetEvents as function() as HRESULT
GetInfo as function() as HRESULT
SetOutput as function() as HRESULT
GetOutputObjectToken as function() as HRESULT
GetOutputStream as function() as HRESULT
rem done
Pause as function(byval as ISpVoice ptr) as HRESULT
Resume as function(byval as ISpVoice ptr) as HRESULT
rem stubs
SetVoice as function() as HRESULT
GetVoice as function() as HRESULT
rem done
Speak as function(byval as ISpVoice ptr, byval pwcs as wstring ptr, byval dwFlags as DWORD, byval pulStreamNumber as ULONG ptr) as HRESULT
rem stubs
SpeakStream as function() as HRESULT
GetStatus as function() as HRESULT
Skip as function() as HRESULT
SetPriority as function() as HRESULT
GetPriority as function() as HRESULT
SetAlertBoundary as function() as HRESULT
GetAlertBoundary as function() as HRESULT
rem done
SetRate as function(byval as ISpVoice ptr, byval RateAdjust as integer) as HRESULT
GetRate as function(byval as ISpVoice ptr, byval RateAdjust as integer ptr) as HRESULT
SetVolume as function(byval as ISpVoice ptr, byval usVolume as ushort) as HRESULT
GetVolume as function(byval as ISpVoice ptr, byval pusVolume as ushort ptr) as HRESULT
WaitUntilDone as function(byval as ISpVoice ptr, byval msTimeout as ULONG) as HRESULT
rem stubs
SetSyncSpeakTimeout as function() as HRESULT
GetSyncSpeakTimeout as function() as HRESULT
SpeakCompleteEvent as function() as HRESULT
IsUISupported as function() as HRESULT
DisplayUI as function() as HRESULT
end type
Save this one as speech.bas
option explicit
#include once "windows.bi"
#include once "win/winnt.bi"
#include once "win/objbase.bi"
#include once "sapi.bi"
#inclib "ole32"
dim voice as ISpVoice ptr
dim text as wstring * 14 => "Hello, World"
CoInitialize(NULL)
CoCreateInstance(@CLSID_SpVoice, NULL, CLSCTX_ALL, @IID_ISpVoice, cast (any ptr, @voice))
voice->lpVtbl->Speak(voice, text, SPF_DEFAULT, NULL)
voice->lpVtbl->WaitUntilDone(voice, INFINITE)
voice->lpVtbl->Release(voice)
CoUninitialize()
Save both files into the same folder.
Jim