config['secret_id'], $this->config['secret_key']); $httpProfile = new HttpProfile(); $httpProfile->setEndpoint("asr.tencentcloudapi.com"); $clientProfile = new ClientProfile(); $clientProfile->setHttpProfile($httpProfile); $client = new AsrClient($cred, "", $clientProfile); $req = new SentenceRecognitionRequest(); $params = array( "ProjectId" => 0, "SubServiceType" => 2, "EngSerViceType" => $eng_ser_vice_type, "SourceType" => $source_type, "VoiceFormat" => $voice_format, "UsrAudioKey" => $user_audio_key, ); if ($source_type == 0) { $params['Url'] = $content; } else if ($source_type == 1) { $params['Data'] = $content; $params['DataLen'] = $data_length; } $req->fromJsonString(json_encode($params)); $resp = $client->SentenceRecognition($req); $resp = $resp->toJsonString(); return json_decode($resp, true); } catch (TencentCloudSDKException $e) { echo $e; } } }