openai的chatgpt文本生成语音api示例php代码

代码语言:php

所属分类:其他

代码描述:openai的chatgpt文本生成语音api示例php代码

代码标签: openai chatgpt 文本 生成 语音 api 示例 php 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<?php

$openaiApiKey = "YOUR_OPENAI_API_KEY"; // 替换为您的 OpenAI API 密钥

$url = "https://api.openai.com/v1/audio/speech";

$data = array(
    "model" => "tts-1",
    "input" => "Today is a wonderful day to build something people love!",
    "voice" => "alloy"
);

$data_string = json_encode($data);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_st.........完整代码请登录后点击上方下载按钮下载查看

网友评论0