jingfengshi / baidu-voice
语音SDK
0.0.1
2019-01-04 06:09 UTC
This package is auto-updated.
Last update: 2024-09-04 21:29:39 UTC
README
🌈 基于百度语音接口的PHP获取语音内容的信息组件
安装
$ composer require jingfengshi/baidu-voice -vvv
使用
use jingfengshi\BaiduVoice\AiSpeech; $appId='xxx'; $appKey='xxx'; $appSecret='xxx'; $ai_speech=new AiSpeech($appId,$appKey,$appSecret); $res=$ai_speech->getContentFromVoice(file_get_contents(public_path().'/test.pcm'),'pcm',8000); dd($res)
在Laravel中使用
在laravel中使用也是同样的安装方式,配置写在 config/service.php
中
. . . 'weather' => [ 'appId' => env('BAIDU_VOICE_API_ID'), 'appKey' => env('BAIDU_VOICE_API_KEY'), 'appSecret' => env('BAIDU_VOICE_API_SECRET'), ],
然后在 .env
中配置BAIDU_VOICE_API_ID
BAIDU_VOICE_API_ID=xxxx
可以使用两种方式来获取 jingfengshi\BaiduVoice\AiSpeech
实例
方法参数注入
. . . public function edit(AiSpeech $aiSpeech) { $response = $weather->getContentFromVoice(file_get_contents(public_path().'/test.pcm'),'pcm',8000); } . . .
服务名访问
. . . public function edit() { $response = app('AiSpeech')->getContentFromVoice(file_get_contents(public_path().'/test.pcm'),'pcm',8000);; } . . .
贡献
您可以通过以下三种方式之一进行贡献:
代码贡献过程并不非常正式。您只需确保遵循PSR-0、PSR-1和PSR-2编码规范。任何新的代码贡献都必须附有适用的单元测试。
许可证
MIT