File tree Expand file tree Collapse file tree 1 file changed +31
-2
lines changed
articles/ai-services/openai/includes Expand file tree Collapse file tree 1 file changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,34 @@ pip install openai==0.28.1
36
36
37
37
1 . Replace the contents of quickstart.py with the following code. Modify the code to add your deployment name:
38
38
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
40
67
import openai
41
68
import time
42
69
import os
@@ -59,7 +86,9 @@ pip install openai==0.28.1
59
86
)
60
87
61
88
print (result)
62
- ```
89
+ ```
90
+
91
+ ---
63
92
64
93
Run the application with the python command on your quickstart file:
65
94
You can’t perform that action at this time.
0 commit comments