使用说明:直接把silk文件的base64编码发送到该接口,该接口解码后输出mp3的base64编码,将编码解码后写入文件就可以了。接口简单,不存储任何数据所以响应很快。

​

/**
* PHP SILK 转 MP3
* @param string $base64
* @return array
* @throws \Exception
*/
function decodeSilk(string $base64 = '') {
        $ch = curl_init();
        curl_setopt_array($ch, [
            CURLOPT_URL => "https://tools.silk.klgwe.online",
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST => true,
            CURLOPT_HTTPHEADER => [
                'Content-Type: application/json',
                'Accept: application/json'
            ],
            CURLOPT_POSTFIELDS => json_encode([
                'base64' => $base64
            ], JSON_UNESCAPED_UNICODE)
        ]);
        $response = curl_exec($ch);
        if (curl_errno($ch)) {
            throw new \Exception(curl_error($ch));
        }
        curl_close($ch);
        $response = json_decode($response, true);
        if (is_array($response) && $response['code'] === 1 && isset($response['data'])) {
            // 返回mp3的 base64编码
            return $response['data'];
        }
        throw new \Exception('解码失败!');
}

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐