php调用openai api实现文本转语音tts示例代码
代码语言:php
所属分类:其他
代码描述:php调用openai api实现文本转语音tts示例代码
代码标签: php 调用 openai api 文本 转 语音 tts 示例 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<?php $openai_api_key = 'YOUR_OPENAI_API_KEY'; // Replace this with your OpenAI API key // The data to send in the request $data = [ 'model' => 'tts-1', 'input' => 'Today is a wonderful day to build something people love!', 'voice' => 'alloy' ]; // Initialize a cURL session $ch = curl_init('https://api.openai.com/v1/audio/speech'); // Set the cURL options curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_H.........完整代码请登录后点击上方下载按钮下载查看
网友评论0