在IIS上通过COM使用SAPI和PHP的问题
发布时间:2020-12-13 22:25:22 所属栏目:PHP教程 来源:网络整理
导读:我试图通过COM对象使用Microsoft的SAPI在 PHP中使用Text To Speech和Speech Recognition. 在过去,我已经使用此代码使TTS工作(Apache 2.1,PHP 5.5,在Windows 2003 Server上) // Instantiate the object$VoiceObj = new COM("SAPI.SpVoice") or die("Unable to
我试图通过COM对象使用Microsoft的SAPI在
PHP中使用Text To Speech和Speech Recognition.
在过去,我已经使用此代码使TTS工作(Apache 2.1,PHP 5.5,在Windows 2003 Server上) // Instantiate the object $VoiceObj = new COM("SAPI.SpVoice") or die("Unable to instantiate SAPI"); // Get the available voices $VoicesToken=$VoiceObj->GetVoices(); $NumberofVoices=$VoicesToken->Count; for($i=0;$i<$NumberofVoices;$i++) { $VoiceToken=$VoicesToken->Item($i); $VoiceName[$i]=$VoiceToken->GetDescription(); } // Get and print the id of the specified voice $SelectedVoiceToken=$VoicesToken->Item(0); $SelectedVoiceTokenid=$SelectedVoiceToken->id; // Set the Voice $VoiceObj->Voice=$SelectedVoiceToken; $VoiceName=$VoiceObj->Voice->GetDescription(); $VoiceFile = new COM("SAPI.SpFileStream"); $VoiceFile->Open('./test.wav',3,false); // Speak to file $VoiceObj->AudioOutputStream = $VoiceFile; $VoiceObj->Speak("What an unbelievable test",0); $VoiceFile->Close(); 在我的新设置(IIS 7.5,PHP 7.0,Windows Server 2008R2)上,相同的代码失败了 $VoiceObj->Speak("What an unbelievable test",0); Fatal error: Uncaught com_exception: <b>Source:</b> Unknown<br/><b>Description:</b> Unknown in webtts.php:30 Stack trace: #0 webtts.php(30): com->Speak('this is a marve...',0) #1 {main} 有这么小的细节(在哪里检索更多?)我无法弄清楚问题可能是什么. 写入权限已检查. 任何提示? 解决方法
两年后,我偶然碰巧找到了这个问题的答案.
即使具有所有必需的权限,PHP COM对象也无法在网络路径上执行文件操作 一旦开发文件夹在IIS运行的同一台机器上移动,一堆先前损坏的测试就开始工作了.它们都有一个共同点:它们使用COM接口来保存文件或类似的东西. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |