
#  Transcribing a non-English language

```
Exercise ID 1590070
```

##  Assignment 

The Whisper model can not only transcribe English language, but also performs well on speech in many other languages.

In this exercise, you’ll create a transcript from `audio.m4a`, which contains speech in Portuguese.

##  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-portuguese.m4a", "audio.m4a")
```



##  Instructions 

- Assign your API key to `openai.api_key`.
- Open the [`audio.m4a`](https://assets.datacamp.com/production/repositories/6309/datasets/443390237150862833705a6e0599478575a1276a/audio-portuguese.m4a) file.
- Create a request to the `Audio` endpoint to transcribe `audio.m4a`.



```
# Set your API key
openai.api_key = "____"

# Open the audio.m4a file
audio_file= ____

# Create a transcript from the audio file
response = ____

print(response["text"])
```

##  Hints 

- Transcribing audio in a non-English language is the same process as for English language: `open()` the audio file, then create a transcribe request to the Whisper model via the `Audio` endpoint.



##  Solution 

```
# Set your API key
openai.api_key = "<OPENAI_API_TOKEN>"

# Open the audio.m4a file
audio_file= open("audio.m4a", "rb")

# Create a transcript from the audio file
response = openai.Audio.transcribe("whisper-1", audio_file)

print(response["text"])
```


