智增增API
API登录演示ChatAPI应用示例最新消息
API登录演示ChatAPI应用示例最新消息
Github地址
智增增官网
  1. 示例代码
  • 欢迎使用智增增
  • 概述
  • HelloWord-第一个示例
  • 标准OpenAI接口列表
    • 【特别注意事项】
    • Introduction介绍
    • Audio 音频
    • Chat 聊天
    • Completions 补全(Legacy)
    • Embeddings 嵌入
    • Fine-tuning 微调
    • Batch 批处理
    • Files 文件
    • Images 图像
    • Models 模型
    • Moderations 审核
  • 自有API接口
    • 查询余额
    • Modify fine-tune
  • 模型说明
    • 模型和价格说明
    • 其它模型示例
    • 费用计算说明
  • 其它说明
    • 主要概念
    • 常见问题
    • base_url地址到底是哪个?
    • 更新记录
  • 接口示例
    • 模型调用示例
    • API应用示例
    • 示例场景
    • 示例代码
      • audio_transcriptions(语音识别)
      • c#语言(支持Unity)
      • c++语言
      • curl
      • gpt-4-vision.图片理解
      • java语言(支持android)
      • js
      • langchain的支持
      • object-c语言(支持苹果IOS)
      • php
      • python
      • translation(识别并翻译成英文)
      • tts.speech.语音合成
      • 兼容openai的Node.js库
      • 兼容openai的python库
      • 兼容openai的其它各种库
      • 函数调用
      • 文字生成图片
      • 流式示例stream
  • fine-tune.微调
    • 微调常见错误
    • 微调示例
    • finetune特别注意事项
  • assistant.助手
    • assistant示例
  • batch.批处理
    • batch示例
    • batch特别注意事项
  • Documentation 使用手册
  • 文章列表
    • 智增增-AI工具配置使用指南
    • 大模型怎么实现连续对话(记忆上下文)
    • ChatGPT-Next-Web使用指南
    • 为什么调用chatgpt的api接口没有返回??怎么查问题
  1. 示例代码

tts.speech.语音合成

语音合成的示例。详细参数参考openai的官网说明:
https://platform.openai.com/docs/api-reference/audio/createSpeech
要注意openai的python包的版本升级了。。。
import os
from openai import OpenAI
import openai
import requests
import time
import json
import time

API_SECRET_KEY = "xxxx"; #智增增的key
BASE_URL = "https://api.zhizengzeng.com/v1/"; #智增增的base_url

# speech
def tts(query):
    openai.api_key = API_SECRET_KEY
    openai.base_url = BASE_URL
    speech_file_path = "test.mp3";
    response = openai.audio.speech.create(
        model="tts-1",
        voice="alloy",
        input=query
    )
    response.stream_to_file(speech_file_path)

if __name__ == '__main__':
    start = time.time();
    tts("今天是星期二");
    end = time.time()
    print('本次处理时间(s): ', end - start)
上一页
translation(识别并翻译成英文)
下一页
兼容openai的Node.js库
Built with