You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- An Azure OpenAI resource created in a supported region (see [Region availability](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability)). For more information, see [Create a resource and deploy a model with Azure OpenAI](../how-to/create-resource.md).
23
22
24
23
25
-
#### [JavaScript](#tab/javascript)
24
+
#### [TypeScript](#tab/typescript)
26
25
27
26
- An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services?azure-portal=true)
28
27
-[LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
- An Azure OpenAI resource created in a supported region (see [Region availability](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability)). For more information, see [Create a resource and deploy a model with Azure OpenAI](../how-to/create-resource.md).
30
30
31
-
---
32
-
33
-
34
-
## Passwordless authentication is recommended
35
31
36
-
For passwordless authentication, you need to
37
32
38
-
1. Use the `@azure/identity` package.
39
-
1. Assign the `Cognitive Services User` role to your user account. This can be done in the Azure portal under **Access control (IAM)** > **Add role assignment**.
40
-
1. Sign in with the Azure CLI such as `az login`.
33
+
---
41
34
42
35
## Set up
43
36
@@ -112,16 +105,16 @@ Your app's _package.json_ file will be updated with the dependencies.
112
105
## Create a speech file
113
106
114
107
115
-
#### [TypeScript](#tab/typescript)
116
108
117
-
1. Create a new file named _Text-to-speech.ts_ and open it in your preferred code editor. Copy the following code into the _Text-to-speech.ts_ file:
throw new Error(`Failed to generate audio stream: ${response.statusText}`);
@@ -243,11 +229,19 @@ Your app's _package.json_ file will be updated with the dependencies.
243
229
});
244
230
245
231
```
232
+
233
+
The "openai/shims/node"import supports the ability for the a stream type that changes depending on whether you run in Node.js or in another environment suchasa browser.
234
+
235
+
1. Build the application with the following command:
- An Azure OpenAI resource created in a supported region (see [Region availability](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability)). For more information, see [Create a resource and deploy a model with Azure OpenAI](../how-to/create-resource.md).
22
21
23
22
24
-
#### [JavaScript](#tab/javascript)
23
+
24
+
#### [TypeScript](#tab/typescript)
25
25
26
26
- An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services?azure-portal=true)
27
27
-[LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
- An Azure OpenAI resource created in a supported region (see [Region availability](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability)). For more information, see [Create a resource and deploy a model with Azure OpenAI](../how-to/create-resource.md).
29
30
31
+
30
32
---
31
33
32
34
@@ -111,14 +113,15 @@ Your app's _package.json_ file will be updated with the dependencies.
111
113
112
114
## Create a sample application
113
115
114
-
#### [TypeScript](#tab/typescript)
116
+
117
+
#### [JavaScript](#tab/javascript)
115
118
116
119
1. Create a new file named _Whisper.js_ and open it in your preferred code editor. Copy the following code into the _Whisper.js_ file:
117
-
118
-
```typescript
119
-
import"dotenv/config";
120
-
import { createReadStream } from"fs";
121
-
import { AzureOpenAI } from"openai";
120
+
121
+
```javascript
122
+
require("dotenv/config");
123
+
const { createReadStream } =require("fs");
124
+
const { AzureOpenAI } =require("openai");
122
125
123
126
// You will need to set these environment variables or edit the following values
0 commit comments