ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` function voice_generate($text,$path="./"){ require_once './jpltcommon/voice/AipSpeech.php'; // 你的 APPID AK SK $APP_ID = '18292366'; $API_KEY = 'WpNg4xVzYVobpVexcqDFGw25'; $SECRET_KEY = 'ryQHjupKjxY1ssIu1MiOBbpjIG39qb1x'; /*spd String 语速,取值0-9,默认为5中语速 否 pit String 音调,取值0-9,默认为5中语调 否 vol String 音量,取值0-15,默认为5中音量 否 per String 发音人选择, 0为女声,1为男声, 3为情感合成-度逍遥,4为情感合成-度丫丫,默认为普通女*/ $client = new AipSpeech($APP_ID,$API_KEY, $SECRET_KEY); $result = $client->synthesis($text, 'zh', 1, array( 'vol' => 5, 'spd' => 3, 'pit' => 3, 'per' => 1, )); // var_dump( $result);die; // 识别正确返回语音二进制 错误则返回json 参照下面错误码 $time=time(); if(!is_array($result)){ file_put_contents($path.$time.'.mp3', $result); } return $path.$time.'.mp3'; } /* 百度语音识别 $path 路径 $format 类型 */ function voice_identify($path,$format){ require_once './jpltcommon/voice/AipSpeech.php'; // 你的 APPID AK SK $APP_ID = '18292366'; $API_KEY = 'WpNg4xVzYVobpVexcqDFGw25'; $SECRET_KEY = 'ryQHjupKjxY1ssIu1MiOBbpjIG39qb1x'; $client = new AipSpeech($APP_ID,$API_KEY, $SECRET_KEY); $cz=$client->asr(file_get_contents($path), $format, 16000, array('dev_pid' => 1536,)); return $cz; // var_dump($cz,1);die; } ```