4
我正在嘗試使用Microsoft的SAPI通過COM對象使文本到語音和語音識別在PHP中工作。在IIS上使用SAP通過COM使用SAPI的問題
在過去,我已經使用這個代碼來獲取TTS工作(阿帕奇2.1,PHP 5.5,Windows 2003服務器上)
// 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 \\web\tts.php:30 Stack trace: #0 \\web\tts.php(30): com->Speak('this is a marve...', 0) #1 {main}
有這麼小的細節(哪裏檢索更多?
檢查寫入權限。 PHP 7.0替換爲5.5,仍然無法正常工作。 使用Win32應用程序測試過相同的代碼,並且工作完美無瑕。
任何提示?