| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 | 
							- <?php
 
- /**
 
-  * Created by PhpStorm.
 
-  * User: 97
 
-  */
 
- namespace app\admin\controller;
 
- use app\BaseController;
 
- use Darabonba\OpenApi\OpenApiClient;
 
- use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
 
- use Darabonba\OpenApi\Models\Config;
 
- use Darabonba\OpenApi\Models\Params;
 
- use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
 
- use Darabonba\OpenApi\Models\OpenApiRequest;
 
- use think\facade\Env;
 
- class Index extends BaseController{
 
-     public function index(){
 
- //        echo 'index-admin';
 
-          $overview = $_GET['overview'];
 
-          $audiourl = $_GET['audiourl'];
 
-          if(!$overview){
 
-              echo "请传入音频解析方向的描述";
 
-              die;
 
-          }
 
-         if(!$audiourl){
 
-             echo "请传入音频文件链接";
 
-             die;
 
-         }
 
-         $result = $this->createTaskOneInfo($audiourl,$overview);
 
-         var_dump($result);
 
-     }
 
-     public function indextwo(){
 
- //        echo 'index-admin';
 
-         $taskid = $_GET['taskid'];
 
-         if(!$taskid){
 
-             echo "请传入听悟任务的ID";
 
-             die;
 
-         }
 
-         $result = $this->getTaskOneInfo($taskid);
 
-         var_dump($result);
 
-     }
 
-     /**
 
-      * 使用AK&SK初始化账号Client
 
-      * @return OpenApiClient Client
 
-      */
 
-     public static function createClient(){
 
-         // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
 
-         // 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/311677.html。
 
-         $config = new Config([
 
-             // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
 
-             "accessKeyId" => Env::get("AliyunTingwu.AccessKeyId"),
 
-             // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
 
-             "accessKeySecret" => Env::get("AliyunTingwu.AccessKeySecret")
 
-         ]);
 
-         // Endpoint 请参考 https://api.aliyun.com/product/tingwu
 
-         $config->endpoint = "tingwu.cn-beijing.aliyuncs.com";
 
-         return new OpenApiClient($config);
 
-     }
 
-     /**
 
-      * API 相关
 
-      * @return Params OpenApi.Params
 
-      */
 
-     public static function createTaskApiInfo(){
 
-         $params = new Params([
 
-             // 接口名称
 
-             "action" => "CreateTask",
 
-             // 接口版本
 
-             "version" => "2023-09-30",
 
-             // 接口协议
 
-             "protocol" => "HTTPS",
 
-             // 接口 HTTP 方法
 
-             "method" => "PUT",
 
-             "authType" => "AK",
 
-             "style" => "ROA",
 
-             // 接口 PATH
 
-             "pathname" => "/openapi/tingwu/v2/tasks",
 
-             // 接口请求体内容格式
 
-             "reqBodyType" => "json",
 
-             // 接口响应体内容格式
 
-             "bodyType" => "json"
 
-         ]);
 
-         return $params;
 
-     }
 
-     /**
 
-      * @param string[] $args
 
-      * @return void
 
-      */
 
-     public static function createTaskOneInfo($audiourl='',$overview=''){
 
-         $client = self::createClient();
 
-         $params = self::createTaskApiInfo();
 
-         // query params
 
-         $queries = [];
 
-         $queries["type"] = "offline";
 
-         // body params
 
- //        $body = [
 
- //            "AppKey" => "jB3lTWgWwCCmO12g",
 
- //            "Input" => [
 
- //                "SourceLanguage" => "cn",
 
- //                "FileUrl" => "https://crmapi.kedingdang.com/Intentionclient/getHuijieCallidRecordingFile?callid=9903ca31-b0c5-4d9b-aad1-cd6f97f87c43"
 
- //            ]
 
- //        ];
 
-         //  --- 之前模拟的数据
 
-         //设置数据项  - -  第五层
 
-         $contents = array();
 
-         $contents['Name'] = "test";
 
-         $contents['Prompt'] = $overview?($overview.":\n {Transcription}"):"对话中客户表达的完整内容输出出来,并且请帮我将下面的对话进行总结,分析对话中客户是否有下单意愿以及商品是否感兴趣:\n {Transcription}";
 
-         $contents['Model'] = "tingwu-turbo";
 
-         $contents['TransType'] = "chat";
 
-         //设置数据项  - -  第四层
 
-         $customPrompt = array();
 
-         $customPrompt['Contents'] = $contents;
 
-         //设置数据项  - -  第三层
 
-         $parameters = array();
 
-         $parameters['CustomPromptEnabled'] = 'True';
 
-         $parameters['CustomPrompt'] = $customPrompt;
 
-         $inputone = array();
 
-         $inputone['SourceLanguage'] = 'cn';
 
-         $inputone['TaskKey'] = 'task'.'123123'.time();
 
-         $inputone['FileUrl'] = $audiourl?$audiourl:'https://crmapi.kedingdang.com/Intentionclient/getHuijieCallidRecordingFile?callid=9903ca31-b0c5-4d9b-aad1-cd6f97f87c43';
 
-         //设置数据项  - -  第二层
 
-         $body = array();
 
-         $body['AppKey'] = 'jB3lTWgWwCCmO12g';
 
-         $body['Input'] = $inputone;
 
-         $body['Parameters'] = $parameters;
 
-         // runtime options
 
-         $runtime = new RuntimeOptions([]);
 
-         $request = new OpenApiRequest([
 
-             "query" => OpenApiUtilClient::query($queries),
 
-             "body" => $body
 
-         ]);
 
-         // 复制代码运行请自行打印 API 的返回值
 
-         // 返回值实际为 Map 类型,可从 Map 中获得三类数据:响应体 body、响应头 headers、HTTP 返回的状态码 statusCode。
 
-         $result = $client->callApi($params, $request, $runtime);
 
-         return $result;
 
-     }
 
-     /**
 
-      * API 相关
 
-      * @param string $TaskId
 
-      * @return Params OpenApi.Params
 
-      */
 
-     public static function getTaskApiInfo($TaskId){
 
-         $params = new Params([
 
-             // 接口名称
 
-             "action" => "GetTaskInfo",
 
-             // 接口版本
 
-             "version" => "2023-09-30",
 
-             // 接口协议
 
-             "protocol" => "HTTPS",
 
-             // 接口 HTTP 方法
 
-             "method" => "GET",
 
-             "authType" => "AK",
 
-             "style" => "ROA",
 
-             // 接口 PATH
 
-             "pathname" => "/openapi/tingwu/v2/tasks/" . $TaskId . "",
 
-             // 接口请求体内容格式
 
-             "reqBodyType" => "json",
 
-             // 接口响应体内容格式
 
-             "bodyType" => "json"
 
-         ]);
 
-         return $params;
 
-     }
 
-     /**
 
-      * @param string[] $args
 
-      * @return void
 
-      */
 
-     public static function getTaskOneInfo($args){
 
-         $client = self::createClient();
 
-         $params = self::getTaskApiInfo($args);//"5125c43149db4e01a2bf92bb6d34128b"
 
-         // runtime options
 
-         $runtime = new RuntimeOptions([]);
 
-         $request = new OpenApiRequest([]);
 
-         // 复制代码运行请自行打印 API 的返回值
 
-         // 返回值实际为 Map 类型,可从 Map 中获得三类数据:响应体 body、响应头 headers、HTTP 返回的状态码 statusCode。
 
-         $result = $client->callApi($params, $request, $runtime);
 
-         return $result;
 
-     }
 
- }
 
 
  |