0

This use to work on Windows 10, but now it doesn't, and I can't find how to correct the code to make it work.

void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
  ISpeechObjectTokenPtr token;
  ISpeechObjectTokensPtr tokens;
  tokens=SpVoice1->GetVoices(L"",L"");
  token=tokens->Item(ComboBox1->ItemIndex);
  SpVoice1->Voice=token;
}

Also errors (is not accessible) at:

SpVoice1->Volume
SpVoice->Rate

If I comment out the Voice, Rate, and Volume, it compiles and runs fine.

Windows 10 64-bit build 19041.867

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Spider
  • 1
  • 1
  • 1
    The `Voice`, `Rate`, and `Volume` properties of `SpVoice` are all read/write in the SAPI API. Did you, by chance, re-import the `SpVoice` object into your project and the import somehow produced new wrappers for them that are now read-only or `private`/`protected`, whereas they weren't before? Did you look at the declaration of `TSpVoice` to see how those properties are actually being declared? Also, which version of C++Builder are you using? – Remy Lebeau Mar 25 '21 at 17:21
  • yes, I remove the old wrappers and created new, hoping that would help. don't laugh, but I'm still using C++Builder 6 Enterprise I might try coping the sapi.dll from my windows 8.1 to a temp folder and try importing that – Spider Mar 25 '21 at 17:47
  • Nothing to laugh about. Until recently, I was also still using BCB6 at my job. Frankly, I never liked using the IDE's COM imports, I prefer to always use the COM headers directly (ie, `SAPI.h`) and just use `CoCreateInstance()` manually. Never had a problem with that. – Remy Lebeau Mar 25 '21 at 17:49

1 Answers1

0

just had to make a few changes.

- SpVoice1->Volume=Vol->Position; //(Vol is the name of my trackbar)
+ SpPVoice1->set_Volume(Vol->Position);

- SpVoice1->Rate=Rate->Position;  //(Rate is the name of my trackbar)
+ SpVoice1->set_Rate(Rate->Position);

- SpVoice1->Voice=token;
+ SpVoice1->_set_Voice(token);
Spider
  • 1
  • 1