delz / xfyun
科大讯飞 REST API PHP SDK
Installs: 238
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 1
Forks: 4
pkg:composer/delz/xfyun
Requires
- php: >=7.0.0
- guzzlehttp/guzzle: ~6.3.0
This package is not auto-updated.
Last update: 2025-09-28 10:59:25 UTC
README
如何获取
composer require delz/xfyun
参考文档地址
调用语音合成接口
-
实例化客户端对象
$client = new Client("{APPID}","{APIKEY}");
-
生成TTS对象,并发送请求
try {
$content = $client->createTTS()->setText('您好')->send();
$file = fopen(__DIR__ . '/test.wav',"w");
fwrite($file, $content);
fclose($file);
} catch(ApiException $e) {
echo $e->getMessage();
}
语音听写接口
-
实例化客户端对象
$client = new Client("{APPID}","{APIKEY}");
-
生成IAT对象,并发送请求
try {
$content = $client->createIAT()->setAudio(file_get_contents(__DIR__.'/test.wav'))->send();
echo $content;
} catch(ApiException $e) {
echo $e->getMessage();
}