Closed as not planned
Description
AttributeError: 'Audio' object has no attribute 'speech'
Traceback (most recent call last):
File "/Users/xxx/src/jshare-llm-demo/openai-demo/tts.py", line 12, in
response = client.audio.speech.create(
AttributeError: 'Audio' object has no attribute 'speech'
from pathlib import Path
from openai import OpenAI
client = OpenAI(
# defaults to os.environ.get("OPENAI_API_KEY")
api_key="xxxxxx",
)
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)
=============================
OS: mac OS
python: 3.9.*
openai: 1.0.1
Metadata
Metadata
Assignees
Labels
No labels