You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frompathlibimportPathfromopenaiimportOpenAI# replace https://api.openai.com to access from chinabase_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}}
The text was updated successfully, but these errors were encountered:
报错
The text was updated successfully, but these errors were encountered: