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

**URL:** <https://community.openai.com/t/attributeerror-type-object-audio-has-no-attribute-transcriptions/714319>\
**Category:** Deprecations\
**Tags:** api\
**Created:** [April 10, 2024, 9:36pm UTC](https://community.openai.com/t/attributeerror-type-object-audio-has-no-attribute-transcriptions/714319 "2024-04-10T21:36:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![supamariolox](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/supamariolox/32/448278_2.png) [@supamariolox](https://community.openai.com/u/supamariolox)\
**Post date:** [April 10, 2024, 9:36pm UTC](https://community.openai.com/t/attributeerror-type-object-audio-has-no-attribute-transcriptions/714319/1 "2024-04-10T21:36:24Z")

</div>

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.

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

# Load environment variables from .env file
load_dotenv()
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')

# 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)

    try:
        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(
        model="gpt-4",
        messages=[
            {"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(
        model="tts-1",
        voice="alloy",
        input=chatgpt_response,
        response_format="mp3"
    )

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

    # 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)
            speak_chatgpt_response(chatgpt_response)

```

The weird thing is, this cURL command works:

curl -X POST “h\*\*ps://api.openai.com/v1/audio/speech” -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?

---

<div class="post-metadata">

**Author:** ![supamariolox](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/supamariolox/32/448278_2.png) [@supamariolox](https://community.openai.com/u/supamariolox)\
**Post date:** [April 10, 2024, 9:38pm UTC](https://community.openai.com/t/attributeerror-type-object-audio-has-no-attribute-transcriptions/714319/2 "2024-04-10T21:38:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![noor2021](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/noor2021/32/146405_2.png) [@noor2021](https://community.openai.com/u/noor2021)\
**Post date:** [April 26, 2024, 3:04pm UTC](https://community.openai.com/t/attributeerror-type-object-audio-has-no-attribute-transcriptions/714319/3 "2024-04-26T15:04:22Z")

</div>

![image](https://us1.discourse-cdn.com/openai1/original/4X/3/b/f/3bffe6e27d9dfb094fc0ce76bbb38ca40970e300.png)  
it audio not “Audio”
