AttributeError: type object 'Audio' has no attribute 'transcriptions'

Trying to convert text-to-speech using OpenAI whisper model and I keep getting this error message

I have tried everything, switching to different versions of openai via pip

The code transcribes my voice into text, sends that to chatGPT and gets a response, but the TTS API is not working.

import os
from pathlib import Path
import openai
import speech_recognition as sr
from dotenv import load_dotenv

# Load environment variables from .env file

# Set the OpenAI API key
openai.api_key = OPENAI_API_KEY

# Initialize the speech recognition engine
recognizer = sr.Recognizer()

def transcribe_audio_from_mic():
    """Transcribes audio from the microphone using speech recognition"""
    with sr.Microphone() as source:
        print("Speak something:")
        audio = recognizer.listen(source)

        text = recognizer.recognize_google(audio)
        print("You said:", text)
        return text
    except sr.UnknownValueError:
        print("Could not understand audio")
        return ""
    except sr.RequestError as e:
        print(f"Error from recognition service: {e}")
        return ""

def get_chatgpt_response(prompt):
    """Gets a response from ChatGPT"""
    response = openai.ChatCompletion.create(
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": prompt},
    return response.choices[0].message["content"]

def speak_chatgpt_response(chatgpt_response):
    """Speaks the ChatGPT response using OpenAI's text-to-speech"""
    speech_file_path = Path(__file__).parent / "speech.mp3"
    # Create spoken audio from the ChatGPT response
    response = openai.Audio.create(

    # Write the audio stream to a file
    with open(speech_file_path, "wb") as f:

    # Play the audio file (using the default media player on Windows)
    os.system(f'start {speech_file_path}')

# Main program loop
if __name__ == "__main__":
    while True:
        prompt = transcribe_audio_from_mic()
        if prompt:
            chatgpt_response = get_chatgpt_response(prompt)
            print("ChatGPT:", chatgpt_response)

The weird thing is, this cURL command works:

curl -X POST “h**ps://” -H “Content-Type: application/json” -H “Authorization: Bearer TOKEN-HERE” -d “{"model":"tts-1","input":"The quick brown fox jumped over the lazy dog.","voice":"alloy"}” --output speech.mp3

So obviously the endpoint is able to be reached, but something is not right with my code. Can someone please help?

I have tried changing the speak_chatgpt_response many times. I then get this error: AttributeError: type object ‘Audio’ has no attribute ‘create’

If I upgrade to > version 1.0.0, it breaks the response pulled from ChatGPT. I am using OpenAI 0.28

it audio not “Audio”