This article mainly introduces PHP to generate speech, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
<?php /** * 测试语音 */ require '../common.inc.php'; require DT_ROOT.'/api/speech/AipSpeech.php'; $client = new AipSpeech(APP_ID, API_KEY, SECRET_KEY); $result = $client->synthesis('您有一条财务审批,请注意查收!', 'zh', 1, array( 'vol' => 5,)); // 识别正确返回语音二进制 错误则返回json 参照下面错误码 if(!is_array($result)){ file_put_contents('audio.mp3', $result); } echo ' <embed src="audio.mp3" hidden="false" autostart="true" loop="true" width="0" height="0">'; ?>
Related recommendations:
Two methods for generating QR codes with logo images using PHP
The above is the detailed content of PHP generates speech. For more information, please follow other related articles on the PHP Chinese website!