| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- /**
- * User: admin
- * Date Time: 2021/5/24 20:39
- */
- namespace common\components;
- use Yii;
- use AipSpeech;
- class baiduAip
- {
- //transfer
- public static function transfer($text,$spd=5,$per=0)
- {
- try{
- $client = self::getClient();
- $res = $client->synthesis($text,'zh',1,[
- 'spd'=>$spd,
- 'per'=>$per,
- ]);
- return $res;
- }catch (\Exception $exception){
- }
- return false;
- }
- public static function getClient()
- {
- $appId = Yii::$app->params['baiduAipAppId'];
- $appKey = Yii::$app->params['baiduAipAppKey'];
- $appSecret = Yii::$app->params['baiduAipAppSecret'];
- $client = new AipSpeech($appId,$appKey,$appSecret);
- return $client;
- }
- }
|