17 lines
553 B
Python
17 lines
553 B
Python
import os
|
|
|
|
import httpx
|
|
|
|
|
|
url = os.environ["TTS_UPSTREAM_URL"].rstrip("/") + "/v1/audio/speech"
|
|
headers = {"Content-Type": "application/json"}
|
|
if os.environ.get("TTS_API_KEY"):
|
|
headers["Authorization"] = f"Bearer {os.environ['TTS_API_KEY']}"
|
|
response = httpx.post(
|
|
url,
|
|
headers=headers,
|
|
json={"model": "qwen3-tts", "input": "测试", "voice": "default", "response_format": "wav", "speed": 1},
|
|
timeout=40,
|
|
)
|
|
print(f"status={response.status_code} content_type={response.headers.get('content-type', '')} bytes={len(response.content)}")
|