|
Post by UNDISCLOSED on Jul 18, 2009 2:37:37 GMT -5
|
|
|
Post by DJLinux on Jul 18, 2009 4:29:45 GMT -5
God job
Speak("Oh my god Linux is coming and i must d dd ddd die.")
If you like you can add:
SetSpeed(Value) SetVolume(Value) SetVoice("NAME") ' if any others are aviable
Joshy
|
|
|
Post by UNDISCLOSED on Jul 18, 2009 10:51:39 GMT -5
I am looking into that. This is the source:
#include "Basic4GLPlugin.bi" #include "SAPI.bi"
const PLUGIN_DESC = "Windows SpeechAPI 5 Plugin for Basic4GL" const PLUGIN_MAJOR = 1 const PLUGIN_MINOR = 0
extern "C"
private sub glSpeak(THIS_RUNTIME) DIM text as zString ptr text = GSP(1) Speak(*text) SIR(0) end sub
' ########## ' # Plugin # ' ##########
dim shared as IDLL_Basic4GL_Plugin ptr MyPlugin
' register exported Datatypes,Const's,Function's,Sub's function Load (THIS_PLUGIN , _ THIS_REGISTRY, _ blnIsExe as byte) as integer 'RegisterIntegerFunction(name,address):RegisterIntegerParam,RegisterIntegerParam RIF(Speak,@glSpeak):ASP return 1 end function
' interface sub Unload (THIS_PLUGIN) if MyPlugin then delete MyPlugin MyPlugin = 0 end if end sub
function Start(THIS_PLUGIN) as integer return 1 end function
sub Ends (THIS_PLUGIN)
end sub
sub Pause (THIS_PLUGIN)
end sub
sub Resumed (THIS_PLUGIN)
end sub
sub DelayedResume (THIS_PLUGIN)
end sub
sub GetError (THIS_PLUGIN,ErrMsg as zstring ptr)
end sub
sub ProcessMessages(THIS_PLUGIN)
end sub
' Query function function Basic4GL_Query alias "Basic4GL_Query" (byval details as string, _ byref major as integer, _ byref minor as integer) as integer export dim as string DetailSrc = PLUGIN_DESC for i as integer = 0 to len(detailSrc) Details[i] = DetailSrc[i] next major = PLUGIN_MAJOR minor = PLUGIN_MINOR return BASIC4GL_DLL_VERSION end function
' Main initialisation function. ' Here we will construct and return our plugin object function Basic4GL_Init alias "Basic4GL_Init" () as IDLL_Basic4GL_Plugin ptr ptr export ' Construct and return our plugin object MyPlugin=new IDLL_Basic4GL_Plugin MyPlugin->Load =@Load MyPlugin->Unload =@Unload MyPlugin->Start =@Start MyPlugin->Ends =@Ends MyPlugin->Pause =@Pause MyPlugin->Resumed =@Resumed MyPlugin->DelayedResume =@DelayedResume MyPlugin->GetError =@GetError MyPlugin->ProcessMessages=@ProcessMessages return @MyPlugin end function
end extern
SAPI.bi:
#define UNICODE #include once "disphelper/disphelper.bi"
Declare Sub SpeakEngine (param As Any Ptr)
#Define MAX_BUFFERS 20
Type _RingBuffer rIdx As Integer = 0 wIdx As Integer = 0 End Type
Dim Shared Mutex As Any Ptr Dim Shared IsSpeaking As Integer = 0 Dim Shared Ring As _RingBuffer Dim Shared RingText(MAX_BUFFERS) As Wstring * 255
Sub Speak (Text As String) Dim StartThread As Integer
MutexLock(Mutex)
With Ring RingText(.wIdx) = Text .wIdx += 1 If .wIdx > MAX_BUFFERS Then .wIdx = 0 Endif End With If IsSpeaking = 0 Then IsSpeaking = 1 StartThread = 1 End If
MutexUnLock(Mutex) If StartThread Then ThreadCreate (@SpeakEngine, @IsSpeaking) Endif End Sub
Sub SpeakEngine (param As Any Ptr) Dim SpeakFlag As Integer Ptr = param Dim Text As Wstring * 512 Dim myt As Wstring * 512 Dim As HRESULT hr
MutexLock(Mutex)
With Ring Do Text = RingText(.rIdx) RingText(.rIdx)="" .rIdx += 1 If (.rIdx > MAX_BUFFERS) Then .rIdx = 0 Endif DISPATCH_OBJ(tts) dhInitialize(TRUE) dhToggleExceptions(FALSE) 'set this TRUE to get error codes myt = "Sapi.SpVoice" hr = dhCreateObject(@myt, NULL, @tts) If hr <> 0 Then Exit Sub
MutexUnLock (Mutex) dhCallMethod(tts, ".Speak(%S)", @Text) MutexLock (Mutex) SAFE_RELEASE(tts)
Loop Until (.wIdx - .rIdx) = 0 End With SpeakFlag[0]=0 MutexUnLock(Mutex) End Sub
And it uses your Plugin include
|
|
|
Post by shadow008 on Jul 21, 2009 10:22:47 GMT -5
... like most plugins, it doesnt work for me...
|
|
|
Post by Darkjester on Jul 21, 2009 13:28:12 GMT -5
what do you mean like most plugins? perhaps you are using them wrong.. try reinstalling basic4gl to latest as well as putting the plugins in the basic4gl main folder(where basic4gl.exe is)
|
|
|
Post by UNDISCLOSED on Jul 22, 2009 3:25:07 GMT -5
Well, this one only works if you have Microsoft Speech API V5.0 or above. So you should check that.
|
|
|
Post by Empyrion Martyr on Jul 30, 2009 6:47:05 GMT -5
Great plugin mate! works like a charm
|
|