Project

General

Profile

Actions

Feature #10

closed

SAPI - Float Point division by zero at startup

Added by Jesús M. Broceño over 8 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
Start date:
12/01/2015
Due date:
05/21/2021
% Done:

100%

Estimated time:

Description

When trying to activate SAPI 5.1 I get a Floating Point division by zero

Actions #1

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"

Actions #2

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.

Actions #3

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;
Actions

Also available in: Atom PDF