似乎不支持转发 TTS api 的接口?Invalid URL (POST /audio/speech)
Opened this issue · 0 comments
Jackiexiao commented
from pathlib import Path
from openai import OpenAI
# replace https://api.openai.com to access from china
base_url = "https://xxx.cc/proxy"
api_key = "sk-xxx"
client = OpenAI(
api_key=api_key,
base_url=base_url,
)
speech_file_path = Path(__file__).parent / "speech.mp3"
response = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="Today is a wonderful day to build something people love!",
)
response.stream_to_file(speech_file_path)
print(f"Done! See {speech_file_path}")
报错
Traceback (most recent call last):
File "/Users/jackiexiao/code/openai_tts/demo_tts.py", line 17, in <module>
response = client.audio.speech.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jackiexiao/anaconda3/lib/python3.11/site-packages/openai/resources/audio/speech.py", line 71, in create
return self._post(
^^^^^^^^^^^
File "/Users/jackiexiao/anaconda3/lib/python3.11/site-packages/openai/_base_client.py", line 1055, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jackiexiao/anaconda3/lib/python3.11/site-packages/openai/_base_client.py", line 834, in request
return self._request(
^^^^^^^^^^^^^^
File "/Users/jackiexiao/anaconda3/lib/python3.11/site-packages/openai/_base_client.py", line 877, in _request
raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {'error': {'message': 'Invalid URL (POST /audio/speech)', 'type': 'invalid_request_error', 'param': None, 'code': None}}