
#  Creating a podcast transcript

```
Exercise ID 1590069
```

##  Assignment 

The OpenAI API `Audio` endpoint provides access to the **Whisper** model, which can be used for speech-to-text transcription and translation. In this exercise, you'll create a transcript from a [DataFramed podcast](https://www.datacamp.com/podcast) episode with OpenAI Developer, Logan Kilpatrick.

If you'd like to hear more from Logan, check out the full [ChatGPT and the OpenAI Developer Ecosystem](https://www.datacamp.com/podcast/chat-gpt-and-the-open-ai-developer-ecosystem) podcast episode.

##  Pre exercise code 

```
import shutil
import openai

# Copy file so learners don't need to add directory path
shutil.copy("/usr/local/share/datasets/audio-logan-advocate-openai.mp3", "openai-audio.mp3")
```



##  Instructions 

- Assign your API key to `openai.api_key`.
- Open the [`openai-audio.mp3`](https://assets.datacamp.com/production/repositories/6309/datasets/9e5a65b42c1a9fe8756e30e4d255883a8466b671/audio-logan-advocate-openai.mp3) file.
- Create a transcribe request to the Audio endpoint.
- Extract and print the transcript text from the `response`.



```
# Set your API key
openai.api_key = "____"

# Open the openai-audio.mp3 file
audio_file = ____(____, ____)

# Create a transcript from the audio file
response = openai.____.____("whisper-1", ____)

# Extract and print the transcript text
print(____)
```

##  Hints 

- To open an audio file in Python, call the `open()` function on the filename; make sure to specify that you'd like to read from a binary format with `"rb"`.
- To create a transcript request to the `Audio` endpoint, call the `.transcribe()` method on `openai.Audio`.



##  Solution 

```
# Set your API key
openai.api_key = "<OPENAI_API_TOKEN>"

# Open the openai-audio.mp3 file
audio_file = open("openai-audio.mp3", "rb")

# Create a transcript from the audio file
response = openai.Audio.transcribe("whisper-1", audio_file)

# Extract and print the transcript text
print(response["text"])
```


