学习始皇语音转文本使用

请求地址:https://api.oaifree.com/v1/audio/speech

请求method:POST

请求头:Authorization:Bearer YOUR_ACCESS_TOKEN

这个ACCESS_TOKEN可以在:https://chatgpt.com/api/auth/session 这个地址拿到

请求体:

{
    "model": "tts-1",
    "input": "那个天才的想法这就实现了?你真特么是个天才!",
    "voice": "shimmer",
    "response format": "aac"
}

python代码是从评论区一个大佬抄过来的

from openai import OpenAI

key = "从https://chat.openai.com/api/auth/session获取的"
base_url = "https://api.oaifree.com/v1"
# 从文件中读取文本
with open('input_text.txt', 'r', encoding='utf-8') as file:
    input_text = file.read()

# 初始化客户端
client = OpenAI(
    api_key=key,
    base_url=base_url
)

# 调用语音合成API,使用读取的文本作为输入
response = client.audio.speech.create(
    model="tts-1",
    voice="onyx",
    input=input_text
)

# 假设response对象有一个方法来获取二进制内容,如.content
# 这将直接取决于OpenAI客户端库的实现
# 以下是如何将响应内容保存到文件的示例
with open("output.mp3", "wb") as file:
    file.write(response.content)

input_text.txt是源文本

output.mp3输出文件

8 个赞

:+1:

是语音转文本还是文本转语音?看内容是文本转语音吧

啊,对 我纠正一下 不好意思

plus都是支持的,可以参考一下这个帖子

python也是单请求,不能够并发,这是所有的接口,但是现在可以使用始皇的潘多拉

始皇那边充值后能获得 access_token 吗?

好像不是,这应该是plus账号的

https://api.oaipro.com/ 的 令牌 不能用这些 API 吗?

应该也可以把,我刚来两天,我研究一下

佬辛苦了

希望对你有所帮助

{“error”:{“message”:“you need to have a ChatGPT Plus subscription”,“type”:“unauthorized”,“param”:null,“code”:null}}

mark,学习了

感谢

From #develop:ai to 资源荟萃

1 个赞