zoukankan      html  css  js  c++  java
  • 腾讯-智聆口语评测接入

    本功能基于腾讯云SDK3.0开发,要求PHP版本5.6.33及其以上。

    参考文档:

    腾讯云官方文档:cloud.tencent.com/document/sd…

    腾讯云智聆口语评测文档:cloud.tencent.com/document/ap…

    腾讯云智聆口语评测(Smart Oral Evaluation)英语口语评测服务,是基于英语口语类教育培训场景和腾讯云的语音处理技术,应用特征提取、声学模型和语音识别算法,为儿童和成人提供高准确度的英语口语发音评测。支持单词和句子模式的评测,多维度反馈口语表现。支持单词和句子评测模式,可广泛应用于英语口语类教学应用中。

    本接口为语音和文本的比对,结果返回一个分值

    <?php
    /**
     * Created by PhpStorm.
     * User: Shu_Q_Gang
     * Date: 2018/10/23
     * Time: 15:33
     */
    
    namespace tencent;
    use TencentCloudCommonCredential;
    use TencentCloudCommonProfileClientProfile;
    use TencentCloudCommonProfileHttpProfile;
    use TencentCloudCommonExceptionTencentCloudSDKException;
    use TencentCloudSoeV20180724SoeClient;
    use TencentCloudSoeV20180724ModelsTransmitOralProcessWithInitRequest;
    
    class OralAssessment
    {
        /**
         * @var string
         * 密钥  申请地址:https://console.cloud.tencent.com/cam/capi
         */
        protected $SecretId = '**********';
    
        protected $SecretKey = '***********';
    
        /**
         * @var string
         * 地区
         */
        public $Region = "ap-beijing";
    
        /**
         * @var string
         * 流式数据包的序号,从1开始,当IsEnd字段为1后后续序号无意义,当IsLongLifeSession不为1且为非流式模式时无意义。
         */
        public $SeqId  = 1;
    
        /**
         * @var string
         * 是否传输完毕标志,若为0表示未完毕,若为1则传输完毕开始评估,非流式模式下无意义。
         */
        public $IsEnd  = 1;
    
        /**
         * @var string
         * 语音文件类型 1: raw, 2: wav, 3: mp3, 4: speex (语言文件格式目前仅支持 16k 采样率 16bit 编码单声道,如有不一致可能导致评估不准确或失败)。
         */
        public $VoiceFileType  = 2;
    
        /**
         * @var string
         * 语音编码类型 1:pcm。
         */
        public $VoiceEncodeType  = 1;
    
        /**
         * @var string
         * 语音输入模式,0:流式分片,1:非流式一次性评估
         */
        public $WorkMode  = 1;
    
        /**
         * @var string
         * 评估模式,0:词模式(中文评测模式下为文字模式),1:句子模式,2:段落模式,3:自由说模式,当为词模式评估时,能够提供每个音节的评估信息,当为句子模式时,能够提供完整度和流利度信息,4:单词纠错模式:能够对单词和句子中的读错读音进行纠正,给出参考正确读音。
         */
        public $EvalMode  = 1;
    
        /**
         * @var string
         * 评价苛刻指数,取值为[1.0 - 4.0]范围内的浮点数,用于平滑不同年龄段的分数,1.0为小年龄段,4.0为最高年龄段
         */
        public $ScoreCoeff  = 1.0;
    
        /*
         * 发音数据传输接口附带初始化过程
         * $UserVoiceData 要测试的录音 bese64 位格式
         * $SessionId 标识id 时间戳即可 只能是字符串类型
         * $RefText 要比对的文字
         */
        public function TransmitOralProcessWithInit($UserVoiceData,$SessionId,$RefText){
            $cred = new Credential($this->SecretId, $this->SecretKey);
            $httpProfile = new HttpProfile();
            $httpProfile->setEndpoint("soe.tencentcloudapi.com");
    
            $clientProfile = new ClientProfile();
            $clientProfile->setHttpProfile($httpProfile);
            $client = new SoeClient($cred, $this->Region, $clientProfile);
    
            $req = new TransmitOralProcessWithInitRequest();
    
            $params['SeqId'] = $this->SeqId;
            $params['IsEnd'] = $this->IsEnd;
            $params['VoiceFileType'] = $this->VoiceFileType;
            $params['VoiceEncodeType'] = $this->VoiceEncodeType;
            $params['UserVoiceData'] = $UserVoiceData;
            $params['SessionId'] = $SessionId;
            $params['RefText'] = $RefText;
            $params['WorkMode'] = $this->WorkMode;
            $params['EvalMode'] = $this->EvalMode;
            $params['ScoreCoeff'] = $this->ScoreCoeff;
    
    
            $req->fromJsonString(json_encode($params));
            $resp = $client->TransmitOralProcessWithInit($req);
            return json_decode($resp->toJsonString(),true);
        }
    
    }
  • 相关阅读:
    真情感动看上海新闻娱乐频道“百家心”
    Treeview Navigation Web Part for SharePoint with SmartPart v1.0
    轻松玩转Typed DataSet, Part III
    微软Avalon和WinForms的发展蓝图
    Proxy Pattern using C#
    System.Threading.Timer类的TimerCallback 委托
    SmartPart v1.0 for SharePoint [Free Web Part]
    分布式应用架构中的数据传输对象(DTO)
    定制SharePoint Portal Server 2003站点的向导
    Bridge Pattern using C#
  • 原文地址:https://www.cnblogs.com/jucheng/p/12201138.html
Copyright © 2011-2022 走看看