| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?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,
- 'aue'=>6,
- ]);
- 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;
- }
- }
|