Skip to content

AttributeError: 'Audio' object has no attribute 'speech' in 1.0.1 #683

Closed as not planned
@janewu77

Description

@janewu77

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions