config['secret_id'], $this->config['secret_key']); $httpProfile = new HttpProfile(); $httpProfile->setEndpoint("tts.tencentcloudapi.com"); $clientProfile = new ClientProfile(); $clientProfile->setHttpProfile($httpProfile); $client = new TtsClient($cred, $region, $clientProfile); $req = new TextToVoiceRequest(); $params = array( "Region" => $region, "Text" => $text, "SessionId" => $session_id, "ModelType" => 1, "Volume" => $volume, "Speed" => $speed, "VoiceType" => $voice_type, "PrimaryLanguage" => $primary_language, "SampleRate" => $sample_rate, "Codec" => $codec, ); $req->fromJsonString(json_encode($params)); $resp = $client->TextToVoice($req); $resp = $resp->toJsonString(); return json_decode($resp, true); } catch (TencentCloudSDKException $e) { echo $e; } } }