jingfengshi / baidu-voice
A voice SDK
0.0.1
2019-01-04 06:09 UTC
This package is auto-updated.
Last update: 2025-06-04 23:08:07 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);; } . . .
Contributing
You can contribute in one of three ways:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
License
MIT