Skip to content

Commit 8323e95

Browse files
committed
fix 1.x code block
1 parent 2c4b5db commit 8323e95

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

articles/ai-services/openai/includes/whisper-python.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,34 @@ pip install openai==0.28.1
3636

3737
1. Replace the contents of quickstart.py with the following code. Modify the code to add your deployment name:
3838

39-
```python
39+
# [OpenAI Python 1.x](#tab/python-new)
40+
41+
```python
42+
import os
43+
from openai import AzureOpenAI
44+
45+
client = AzureOpenAI(
46+
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
47+
api_version="2024-02-01",
48+
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
49+
)
50+
51+
deployment_id = "YOUR-DEPLOYMENT-NAME-HERE" #This will correspond to the custom name you chose for your deployment when you deployed a model."
52+
audio_test_file = "./wikipediaOcelot.wav"
53+
54+
result = client.audio.transcriptions.create(
55+
file=open(audio_test_file, "rb"),
56+
model=deployment_id
57+
)
58+
59+
print(result)
60+
```
61+
62+
# [OpenAI Python 0.28.1](#tab/python)
63+
64+
65+
66+
```python
4067
import openai
4168
import time
4269
import os
@@ -59,7 +86,9 @@ pip install openai==0.28.1
5986
)
6087

6188
print(result)
62-
```
89+
```
90+
91+
---
6392

6493
Run the application with the python command on your quickstart file:
6594

0 commit comments

Comments
 (0)