PHP generates speech

不言
Release: 2023-03-23 20:52:01
Original
3250 people have browsed it

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 &#39;../common.inc.php&#39;;

	require DT_ROOT.&#39;/api/speech/AipSpeech.php&#39;;

        $client = new AipSpeech(APP_ID, API_KEY, SECRET_KEY);

	$result = $client->synthesis(&#39;您有一条财务审批,请注意查收!&#39;, &#39;zh&#39;, 1, array(
        &#39;vol&#39; => 5,));

        // 识别正确返回语音二进制 错误则返回json 参照下面错误码
        if(!is_array($result)){
            file_put_contents(&#39;audio.mp3&#39;, $result);
        }	

       echo &#39; <embed src="audio.mp3" hidden="false" autostart="true" loop="true" width="0" height="0">&#39;;
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template