主题
音频
提供 TTS(文本转语音) 与 STT(语音转文本) 能力。
语音合成 POST
text
POST https://api.nassaapi.xyz/audio/speech请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | ✅ | tts-1 / tts-1-hd |
input | string | ✅ | 要合成的文本 |
voice | string | ✅ | alloy / echo / fable / onyx / nova / shimmer |
response_format | string | ❌ | mp3(默认) / opus / aac / flac |
speed | number | ❌ | 语速倍率 0.25–4.0,默认 1.0 |
示例请求
bash
curl -X POST "https://api.nassaapi.xyz/audio/speech" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxx" \
-d '{
"model": "tts-1",
"input": "你好,欢迎使用NassaApi 中转站。",
"voice": "alloy"
}' \
--output speech.mp3python
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxx",
base_url="https://api.nassaapi.xyz"
)
response = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="你好,欢迎使用NassaApi 中转站。"
)
response.stream_to_file("speech.mp3")javascript
import OpenAI from 'openai';
import fs from 'fs';
const client = new OpenAI({
apiKey: 'sk-xxxx',
baseURL: 'https://api.nassaapi.xyz',
});
const response = await client.audio.speech.create({
model: 'tts-1',
voice: 'alloy',
input: '你好,欢迎使用NassaApi 中转站。',
});
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync('speech.mp3', buffer);语音识别 POST
text
POST https://api.nassaapi.xyz/audio/transcriptions请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | ✅ | whisper-1 |
file | file | ✅ | 音频文件(mp3 / wav / m4a 等) |
language | string | ❌ | ISO 639-1 语言代码,如 zh |
response_format | string | ❌ | json(默认) / text / srt / vtt |
temperature | number | ❌ | 采样温度,0–1 |
示例请求
bash
curl -X POST "https://api.nassaapi.xyz/audio/transcriptions" \
-H "Authorization: Bearer sk-xxxx" \
-F file="@audio.mp3" \
-F model="whisper-1" \
-F language="zh"python
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxx",
base_url="https://api.nassaapi.xyz"
)
with open("audio.mp3", "rb") as f:
response = client.audio.transcriptions.create(
model="whisper-1",
file=f,
language="zh"
)
print(response.text)响应
json
{
"text": "你好,欢迎使用NassaApi 中转站。"
}