Skip to content

Commit bf92e1a

Browse files
Merge pull request #259387 from mgreenegit/powershell-ai-whisper-0
powershell sample for whisper model
2 parents dc069b5 + abb9c52 commit bf92e1a

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
services: ai-services
3+
manager: nitinme
4+
author: mgreenegit
5+
ms.author: migreene
6+
ms.service: openai
7+
ms.topic: include
8+
ms.date: 11/22/2023
9+
---
10+
11+
## PowerShell
12+
13+
Run the following command. You need to replace `YOUR-DEPLOYMENT-NAME-HERE` with the deployment name you chose when you deployed the Whisper model. Entering the model name results in an error unless you chose a deployment name that is identical to the underlying model name.
14+
15+
```powershell-interactive
16+
# Azure OpenAI metadata variables
17+
$openai = @{
18+
api_key = $Env:AZURE_OPENAI_KEY
19+
api_base = $Env:AZURE_OPENAI_ENDPOINT # your endpoint should look like the following https://YOUR_RESOURCE_NAME.openai.azure.com/
20+
api_version = '2023-09-01-preview' # this may change in the future
21+
name = 'YOUR-DEPLOYMENT-NAME-HERE' #This will correspond to the custom name you chose for your deployment when you deployed a model.
22+
}
23+
24+
# Header for authentication
25+
$headers = [ordered]@{
26+
'api-key' = $openai.api_key
27+
}
28+
29+
$form = @{ file = get-item -path './wikipediaOcelot.wav' }
30+
31+
# Send a completion call to generate an answer
32+
$url = "$($openai.api_base)/openai/deployments/$($openai.name)/audio/transcriptions?api-version=$($openai.api_version)"
33+
34+
$response = Invoke-RestMethod -Uri $url -Headers $headers -Form $form -Method Post -ContentType 'multipart/form-data'
35+
return $response.text
36+
```
37+
38+
You can get sample audio files from the [Azure AI Speech SDK repository at GitHub](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/sampledata/audiofiles).
39+
40+
> [!IMPORTANT]
41+
> For production, use a secure way of storing and accessing your credentials like [The PowerShell Secret Management with Azure Key Vault](/powershell/utility-modules/secretmanagement/how-to/using-azure-keyvault). For more information about credential security, see the Azure AI services [security](../../security-features.md) article.
42+
43+
## Output
44+
45+
```text
46+
The ocelot, Lepardus paradalis, is a small wild cat native to the southwestern United States, Mexico, and Central and South America. This medium-sized cat is characterized by solid black spots and streaks on its coat, round ears, and white neck and undersides. It weighs between 8 and 15.5 kilograms, 18 and 34 pounds, and reaches 40 to 50 centimeters 16 to 20 inches at the shoulders. It was first described by Carl Linnaeus in 1758. Two subspecies are recognized, L. p. paradalis and L. p. mitis. Typically active during twilight and at night, the ocelot tends to be solitary and territorial. It is efficient at climbing, leaping, and swimming. It preys on small terrestrial mammals such as armadillo, opossum, and lagomorphs.
47+
```

articles/ai-services/openai/whisper-quickstart.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ author: eric-urban
1010
ms.author: eur
1111
ms.date: 09/15/2023
1212
recommendations: false
13+
zone_pivot_groups: openai-whisper
1314
---
1415

1516
# Quickstart: Speech to text with the Azure OpenAI Whisper model
@@ -75,9 +76,17 @@ echo export AZURE_OPENAI_ENDPOINT="REPLACE_WITH_YOUR_ENDPOINT_HERE" >> /etc/envi
7576
```
7677
---
7778

79+
::: zone pivot="programming-language-powershell"
80+
81+
[!INCLUDE [PowerShell quickstart](includes/whisper-powershell.md)]
82+
83+
::: zone-end
84+
85+
::: zone pivot="rest-api"
7886

7987
[!INCLUDE [REST API quickstart](includes/whisper-rest.md)]
8088

89+
::: zone-end
8190

8291
## Clean up resources
8392

@@ -89,4 +98,4 @@ If you want to clean up and remove an OpenAI resource, you can delete the resour
8998
## Next steps
9099

91100
* Learn more about how to work with Whisper models with the Azure AI Speech [batch transcription](../speech-service/batch-transcription-create.md) API.
92-
* For more examples, check out the [Azure OpenAI Samples GitHub repository](https://aka.ms/AOAICodeSamples)
101+
* For more examples, check out the [Azure OpenAI Samples GitHub repository](https://aka.ms/AOAICodeSamples)

articles/zone-pivot-groups.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,6 +1925,15 @@ groups:
19251925
title: PowerShell
19261926
- id: rest-api
19271927
title: REST (DALL-E 3)
1928+
# Owner: mbullwin
1929+
- id: openai-whisper
1930+
title: Programming languages
1931+
prompt: Choose your preferred usage method
1932+
pivots:
1933+
- id: rest-api
1934+
title: REST
1935+
- id: programming-language-powershell
1936+
title: PowerShell
19281937
# Owner: diberry
19291938
- id: app-service-webjob
19301939
title: WebJob types

0 commit comments

Comments
 (0)