Using PHP with SAPI 5.1 or COM objects

From: Date: Thu, 23 Jan 2003 04:36:08 +0000
Subject: Using PHP with SAPI 5.1 or COM objects
Groups: php.general 
Request: Send a blank email to php-general+get-132922@lists.php.net to get a copy of this message
I have reached the end of my research and reading and I am stuck. Can anyone help me understand why I am not able to SET the voice of my choice with the following PHP code? Everything else works just fine. I should say that I am a novice at both PHP and SAPI so please excuse my simplistic approach on all of this. Here is the PHP 4.3 code using Apache 2.0.43 on a W2K server. // This instantiates the object $VoiceObj = new COM("SAPI.SpVoice") or die("Unable to instantiate SAPI"); // Gets the available voices and prints them $VoicesToken=$VoiceObj->GetVoices(); $NumberofVoices=$VoicesToken->Count; For ($i=0;$i<$NumberofVoices;$i++) { $VoiceToken=$VoicesToken->Item($i); $VoiceName[$i]=$VoiceToken->GetDescription(); print "$VoiceName[$i]................Item Number: $i </br>"; } // Gets and prints the id of the specified voice $SelectedVoiceToken=$VoicesToken->Item(1); $SelectedVoiceTokenid=$SelectedVoiceToken->id; print "$SelectedVoiceTokenid</br>"; // Tries to Sets the voice $VoiceObj->Voice=$SelectedVoiceToken; $VoiceName=$VoiceObj->Voice->GetDescription(); print "$VoiceName</br>"; // This changes the rate of the selected voice $VoiceObj->Rate = "0"; $VoiceObj->Speak("Hello, welcome to my website"); unset($VoiceObj); The result is....... Microsoft Mary................Item Number: 0 ATT DTNV 1.3 Crystal16................Item Number: 1 ATT DTNV 1.3 Mike................Item Number: 2 LH Michael................Item Number: 3 LH Michelle................Item Number: 4 ATT DTNV 1.3 Crystal................Item Number: 5 Microsoft Mike................Item Number: 6 Microsoft Sam................Item Number: 7 Sample TTS Voice................Item Number: 8 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\ATT-DT-13-Crystal 16 Warning: main(): PropPut() failed: Member not found. in C:\talk.php on line 59 Microsoft Mary Is my problem with the code or my understanding of SAPI 5.1? Joe londajm@rcn.com

« previous php.general (#132922) next »