3. Some library files descriptions (version 2.1).
SAPIDLL.DLL - the library, and they don't need any files for work.
Folder Source - the library sources codes for compile with Delphi 7. Do not forget using dcc32.exe (Delphi Console Compiler for Win32 platform)
Source\SAPIINTERFACE.PAS - the interface unit for call the library from other Delphi application.
Folder Delphi 7 - how to use library with Delphi 7 source.
Folder Assembler - how to call with Assembler (TASM), the source is for version 1.2, rename the other library version from SAPIDLL.DLL to SAPI_DLL.DLL
Use link on top on this page to see call samples to other compilers, the is not include to source packet because it is to do this packet too bigger.
4. The SAPIDLL API SDK.
All API is STDCALL
function CreateSpeech:HResult;
Check SAPI 4 and 5 interfaces on your system, you need to call it first. Remember in clean Windows 98 the Speech interfaces not exists, in Windows NT 5.x the SAPI 5 interface is present and default. Please do not forget the SAPI interface and Speech engines is different things, you can have Interfaces on you system, but not have any engines, than you can't call the Speech.
If Speech API initialization is OK - function return 0.
procedure PSpeak(var PText : longword);
Speak the ASSCIZ string in PText address.
procedure Speak( Text : string);stdcall;
Speak Text string on the select engine (Inject text to speech engine).
For Delphi call, for other compiler better use PSpeak.
procedure SelectEngine(EngineName: String);stdcall;
Select the Speech engine by name. See EngineList to know how get list of names of all exists speech engines.
function GetEngineInfo(EngineName: String; var Info: TSpeechEngineInfo):byte;stdcall;
Return Engine information record, see Info record for more details in Source\SAPIINTERFACE.PAS.
Info record values:
Name: String; The speech engine name
Language: String; Language (btw - "Nature" real use how English, not how nature)
Manufacturer: String; Manufacturer ID
Speaker: String; Speaker name (not Engine name, one Engine can have many Speaker)
MaxPitch: Word; I think Pitch, Speed and Volume understanding without comments :)
MinPitch: Word;
MaxSpeed: Longword;
MinSpeed: Longword;
MaxVolume: Longword;
MinVolume: Longword;
function GetEngines:TStrings;
Return list of exists Speech Engine Names. The Delphi TStringList class, that is problem call it from other compiler, sorry.
The engines selected by Name from this list, or by order number in it list.
function GetPitch: Word;
Get current engine pitch value, the engine must be select before call this function.
function GetSpeed: Dword;
Get current engine speed value, the engine must be select before call this function.
function GetVolume: Dword;
Get current engine volume value, the engine must be select before call this function.
procedure SetPitch(const Value: Word);
Select the Pitch, do not forget see the engine info (call GetEngineInfo function) Maximum and Minimum Pitch values before select new value.
procedure SetSpeed(const Value: Dword);
procedure SetVolume(const Value: Dword);
So, this is Speed and Volume call it like Pitch.
function GetMaxPitch: Word;stdcall;
function GetMaxSpeed: Dword;stdcall;
function GetMaxVolume: Dword;stdcall;
function GetMinPitch: Word;stdcall;
function GetMinSpeed: Dword;stdcall;
function GetMinVolume: Dword;stdcall;
This group is duplicate call GetEngineInfo function.
Procedure Pause;stdcall;
Take the pause ON
Procedure Resume;stdcall;
Resume paused speech.
Procedure Stop;stdcall;
Stop and clear speak volley.
procedure DestroySpeech;
Destroy the speech interfaces, free memory. Call befire your application is close.
4.1 API added in version 1.2
function GetEnginesCount:word;
Get exists speech engines count. It is for other compilers, who can't work with Delphi TStringList class.
procedure PSelectEngine(EngineName: LPCTSTR);stdcall;
Select engine by name, where name is pointer to ASCIIZ string.
procedure PSelectEngineNumber(EngineNumber: word);stdcall;
Select engine by number, see GetEngineCount.
function PGetEngines( number : word):LPCTSTR;stdcall;
Get engine name with Number. Use PGetEngines(0..GetEnginesCount-1) to get names all exists engines for non Delphi compilers.
4.2. API added in version 2.1
In version 2.1 is addes the Speech API 4, 5 events (call back API). It is help you to do goot
speech UI.
The CALLBACK API prototipes:
TSpeechEvent = procedure; procedure without parametrs
TPositionEvent = procedure(Position: dword); one dword parametr
TEngineEvent = procedure(Number: integer; Name: string); two parametrs, with Delphi string
TErrorEvent = procedure(Text: string); one parametr with string (it is Delphi string)
The regist API:
procedure RegistOnStart(CallbackAddr: TSpeechEvent);
When engine start speaking.
procedure RegistOnPause(CallbackAddr: TSpeechEvent);
When user paused engine.
procedure RegistOnResume(CallbackAddr: TSpeechEvent);
When user resume speech after pause.
procedure RegistOnStop(CallbackAddr: TSpeechEvent);
When engine Stop, that means the engine fully speak all injected text and ready to read next part of text.
This is one way to speak big text (read books how example). Because if you send big
part of text to engine they is slowdown system and thinking lot of more time, that is not good.
procedure RegistOnUserStart(CallbackAddr: TSpeechEvent);
When user start speaking, the Speak API is call.
procedure RegistOnUserStop(CallbackAddr: TSpeechEvent);
When user Stop speech, that means call Stop API, please do not confuse with Stop event when text is done.
So, if engine complete speaking text you application is get Stop event, when you application
call Stop API then they get UserStop event.
procedure RegistOnPosition(CallbackAddr: TPositionEvent);
Get the current speak position in text (chars from begin of last injected Speaking text)
procedure RegistOnSpeed(CallbackAddr: TPositionEvent);
When speed is changed
procedure RegistOnVolume(CallbackAddr: TPositionEvent);
When Volume is changed
procedure RegistOnPitch(CallbackAddr: TPositionEvent);
When Pitch is changed
procedure RegistOnSelectEngine(CallbackAddr: TEngineEvent);
When new engine select
procedure RegistOnStatusChange(CallbackAddr: TSpeechEvent);
When engine change status, more calls (rely don't use for non debug versions)
procedure RegistOnError(CallbackAddr: TErrorEvent);stdcall;
When SAPIDLL error happens.
Please contact me
Have a nice Windows.
Сайт создан в системе
uCoz