Feature #10
closedSAPI - Float Point division by zero at startup
100%
Description
When trying to activate SAPI 5.1 I get a Floating Point division by zero
Updated by Jesús M. Broceño over 8 years ago
1 - Select Voice on Speaker settings
2 - Enter a text on the "test" panel
3 - click on "speak"
Updated by Jesús M. Broceño over 8 years ago
Suggested solution by using Set8087CW funcion didn't work.
SAPI interface code will be rewritten. And performance optimizations (thread-queues) will be removed. I think not all speech engines supports intensive threading techniques.
Tested on systems affected. Changes work.
PS: MS Mike and MS Mary does not work on Win7 but default voice does.
Updated by Jesús M. Broceño over 1 year ago
- Description updated (diff)
For the benefit of everyone encountering the same problem as I did, the video by François explained there is a bug in SAPI/Windows (some incompatibility somewhere), which makes the following code raise the EZeroDivide exception:
procedure TForm1.FormClick(Sender: TObject);
var
SpVoice: variant;
begin
SpVoice := CreateOleObject('SAPI.SpVoice');
SpVoice.Speak('This is a text.');
end;
The solution, as presented by the video, is to alter the FPU control word:
procedure TForm1.FormClick(Sender: TObject);
var
SpVoice: variant;
SavedCW: Word;
begin
SpVoice := CreateOleObject('SAPI.SpVoice');
SavedCW := Get8087CW;
Set8087CW(SavedCW or $4);
SpVoice.Speak('This is a text.');
Set8087CW(SavedCW);
end;