이 빠른 시작에서는 음성 텍스트 변환에 Azure OpenAI Whisper 모델을 사용하는 방법을 설명합니다. Whisper 모델은 다양한 언어로 인간의 음성을 기록할 수 있으며 다른 언어를 영어로 번역할 수도 있습니다.
비고
Azure OpenAI에서 사용할 수 있는 다른 오디오 모델에 대한 자세한 내용은 오디오 모델을 참조하세요.
Whisper 모델의 파일 크기 제한은 25MB입니다. 25MB보다 큰 파일을 기록해야 하는 경우 Azure AI Speech 일괄 처리 기록 API를 사용할 수 있습니다.
필수 조건
Azure 구독 – 무료로 만드세요.
지원되는 지역에 배포된 음성 텍스트 변환 모델이 있는 Azure OpenAI 리소스입니다. 자세한 내용은 Azure OpenAI를 사용하여 리소스 만들기 및 모델 배포를 참조하세요.
Azure OpenAI 리소스에 대해 최소 Cognitive Services 기여자 역할이 할당되었는지 확인합니다.
자체 데이터가 없으면 GitHub에서 데이터 예를 다운로드합니다.
설정
키 및 엔드포인트 검색
Azure OpenAI에 대해 성공적으로 호출하려면 엔드포인트와 키가 필요합니다.
| 변수 이름 | 가치 |
|---|---|
AZURE_OPENAI_ENDPOINT |
서비스 엔드포인트는 Azure Portal에서 리소스를 검사할 때 키 및 엔드포인트 섹션에서 찾을 수 있습니다. 또는 Azure AI Foundry 포털의 배포 페이지를 통해 엔드포인트를 찾을 수 있습니다. 예제 엔드포인트는 https://docs-test-001.openai.azure.com/입니다. |
AZURE_OPENAI_API_KEY |
이 값은 Azure Portal에서 리소스를 검사할 때 키 및 엔드포인트 섹션에서 찾을 수 있습니다.
KEY1 또는 KEY2를 사용할 수 있습니다. |
Azure Portal에서 해당 리소스로 이동합니다.
엔드포인트 및 키는 리소스 관리 섹션에서 찾을 수 있습니다. 엔드포인트 및 액세스 키를 복사합니다. API 호출을 인증하는 데 모두 필요합니다.
KEY1 또는 KEY2를 사용할 수 있습니다. 항상 두 개의 키를 사용하면 서비스 중단 없이 키를 안전하게 회전하고 다시 생성할 수 있습니다.
환경 변수
키 및 엔드포인트에 대한 영구 환경 변수를 만들고 할당합니다.
중요합니다
주의해서 API 키를 사용합니다. API 키를 코드에 직접 포함하지 말고, 공개적으로 게시하지 마세요. API 키를 사용하는 경우 Azure Key Vault에 안전하게 저장합니다. 앱에서 API 키를 안전하게 사용하는 방법에 대한 자세한 내용은 Azure Key Vault를 사용하여 API 키를 참조하세요.
AI 서비스 보안에 대한 자세한 내용은 Azure AI 서비스에 대한 요청 인증을 참조하세요.
setx AZURE_OPENAI_API_KEY "REPLACE_WITH_YOUR_KEY_VALUE_HERE"
setx AZURE_OPENAI_ENDPOINT "REPLACE_WITH_YOUR_ENDPOINT_HERE"
REST API 요청 및 응답 만들기
BASH 셸에서 다음 명령을 실행합니다. Whisper 모델을 배포할 때 YourDeploymentName을 선택한 배포 이름으로 바꿔야 합니다. 배포 이름이 모델 이름과 반드시 똑같지는 않습니다. 기본 모델 이름과 동일한 배포 이름을 선택하지 않으면 모델 이름을 입력하면 오류가 발생합니다.
curl $AZURE_OPENAI_ENDPOINT/openai/deployments/YourDeploymentName/audio/transcriptions?api-version=2024-02-01 \
-H "api-key: $AZURE_OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@./wikipediaOcelot.wav"
예시 엔드포인트가 포함된 이전 명령의 첫 번째 줄은 다음과 같습니다.
curl https://aoai-docs.openai.azure.com/openai/deployments/{YourDeploymentName}/audio/transcriptions?api-version=2024-02-01 \
GitHub의 Azure AI Speech SDK 리포지토리에서 wikipediaOcelot.wav 같은 샘플 오디오 파일을 가져올 수 있습니다.
중요합니다
프로덕션의 경우 Azure Key Vault와 같은 안전한 방법을 사용하여 자격 증명을 저장하고 액세스합니다. 자세한 내용은 자격 증명 보안을 참조하세요.
출력
{"text":"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."}
필수 조건
- Azure 구독. 무료로 하나를 만들 수 있습니다.
- 지원되는 지역에 배포된 음성 텍스트 변환 모델이 있는 Azure OpenAI 리소스입니다. 자세한 내용은 Azure OpenAI를 사용하여 리소스 만들기 및 모델 배포를 참조하세요.
- Python 3.8 이상
-
osPython 라이브러리입니다.
설정
키 및 엔드포인트 검색
Azure OpenAI에 대해 성공적으로 호출하려면 엔드포인트와 키가 필요합니다.
| 변수 이름 | 가치 |
|---|---|
AZURE_OPENAI_ENDPOINT |
서비스 엔드포인트는 Azure Portal에서 리소스를 검사할 때 키 및 엔드포인트 섹션에서 찾을 수 있습니다. 또는 Azure AI Foundry 포털의 배포 페이지를 통해 엔드포인트를 찾을 수 있습니다. 예제 엔드포인트는 https://docs-test-001.openai.azure.com/입니다. |
AZURE_OPENAI_API_KEY |
이 값은 Azure Portal에서 리소스를 검사할 때 키 및 엔드포인트 섹션에서 찾을 수 있습니다.
KEY1 또는 KEY2를 사용할 수 있습니다. |
Azure Portal에서 해당 리소스로 이동합니다.
엔드포인트 및 키는 리소스 관리 섹션에서 찾을 수 있습니다. 엔드포인트 및 액세스 키를 복사합니다. API 호출을 인증하는 데 모두 필요합니다.
KEY1 또는 KEY2를 사용할 수 있습니다. 항상 두 개의 키를 사용하면 서비스 중단 없이 키를 안전하게 회전하고 다시 생성할 수 있습니다.
환경 변수
키 및 엔드포인트에 대한 영구 환경 변수를 만들고 할당합니다.
중요합니다
주의해서 API 키를 사용합니다. API 키를 코드에 직접 포함하지 말고, 공개적으로 게시하지 마세요. API 키를 사용하는 경우 Azure Key Vault에 안전하게 저장합니다. 앱에서 API 키를 안전하게 사용하는 방법에 대한 자세한 내용은 Azure Key Vault를 사용하여 API 키를 참조하세요.
AI 서비스 보안에 대한 자세한 내용은 Azure AI 서비스에 대한 요청 인증을 참조하세요.
setx AZURE_OPENAI_API_KEY "REPLACE_WITH_YOUR_KEY_VALUE_HERE"
setx AZURE_OPENAI_ENDPOINT "REPLACE_WITH_YOUR_ENDPOINT_HERE"
암호 없는 인증이 권장됨
암호 없는 인증의 경우 다음을 수행해야 합니다.
-
@azure/identity패키지를 사용합니다. - 사용자 계정에
Cognitive Services User역할을 할당합니다. 이 작업은 Azure Portal의 액세스 제어(IAM)>역할 할당 추가에서 수행할 수 있습니다. -
az login과 같은 Azure CLI를 사용하여 로그인합니다.
Python 환경 만들기
다음을 사용하여 OpenAI Python 클라이언트 라이브러리를 설치합니다.
pip install openai
Python 앱 만들기
quickstart.py라는 새 Python 파일을 만듭니다. 선호하는 편집기 또는 IDE에서 이 파일을 엽니다.
quickstart.py의 내용을 다음 코드로 바꿉니다. 코드를 수정하여 배포 이름을 추가합니다.
import os
from openai import AzureOpenAI
client = AzureOpenAI(
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version="2024-02-01",
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
)
deployment_id = "YOUR-DEPLOYMENT-NAME-HERE" #This will correspond to the custom name you chose for your deployment when you deployed a model."
audio_test_file = "./wikipediaOcelot.wav"
result = client.audio.transcriptions.create(
file=open(audio_test_file, "rb"),
model=deployment_id
)
print(result)
빠른 시작 파일에서 python 명령을 사용하여 애플리케이션을 실행합니다.
python quickstart.py
GitHub의 Azure AI Speech SDK 리포지토리에서 wikipediaOcelot.wav 같은 샘플 오디오 파일을 가져올 수 있습니다.
중요합니다
프로덕션의 경우 Azure Key Vault와 같은 안전한 방법을 사용하여 자격 증명을 저장하고 액세스합니다. 자세한 내용은 자격 증명 보안을 참조하세요.
출력
{"text":"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."}
필수 조건
- Azure 구독. 무료로 하나를 만들 수 있습니다.
- 지원되는 지역에 배포된 음성 텍스트 변환 모델이 있는 Azure OpenAI 리소스입니다. 자세한 내용은 Azure OpenAI를 사용하여 리소스 만들기 및 모델 배포를 참조하세요.
- The .NET 8.0 SDK
Microsoft Entra ID 필수 구성 요소
Microsoft Entra ID를 사용하는 권장 키 없는 인증의 경우 다음을 수행해야 합니다.
- Microsoft Entra ID를 사용하여 키 없는 인증에 사용되는 Azure CLI 를 설치합니다.
- 사용자 계정에
Cognitive Services User역할을 할당합니다. Azure Portal의 액세스 제어(IAM)할 수 있습니다.
설정
새 폴더
whisper-quickstart를 만들고 다음 명령을 사용하여 빠른 시작 폴더로 이동합니다.mkdir whisper-quickstart && cd whisper-quickstart다음 명령을 사용하여 새 콘솔 애플리케이션을 만듭니다.
dotnet new consoledotnet add package 명령을 사용하여 OpenAI .NET 클라이언트 라이브러리를 설치합니다.
dotnet add package Azure.AI.OpenAIMicrosoft Entra ID로 권장되는 키 없는 인증의 경우 다음을 사용하여 Azure.Identity 패키지를 설치합니다.
dotnet add package Azure.IdentityMicrosoft Entra ID로 권장되는 키 없는 인증의 경우 다음 명령을 사용하여 Azure에 로그인합니다.
az login
리소스 정보 검색
Azure OpenAI 리소스를 사용하여 애플리케이션을 인증하려면 다음 정보를 검색해야 합니다.
| 변수 이름 | 가치 |
|---|---|
AZURE_OPENAI_ENDPOINT |
이 값은 Azure Portal에서 리소스를 검사할 때 키 및 엔드포인트 섹션에서 찾을 수 있습니다. |
AZURE_OPENAI_DEPLOYMENT_NAME |
이 값은 모델을 배포할 때 배포에 대해 선택한 사용자 지정 이름에 해당합니다. 이 값은 Azure Portal의 리소스 관리>에서 찾을 수 있습니다. |
OPENAI_API_VERSION |
API 버전에 대해 자세히 알아봅니다. 코드에서 버전을 변경하거나 환경 변수를 사용할 수 있습니다. |
빠른 시작 실행
이 빠른 시작의 샘플 코드는 권장되는 키 없는 인증에 Microsoft Entra ID를 사용합니다. API 키를 사용하려는 경우 개체를 DefaultAzureCredential 개체로 AzureKeyCredential 바꿀 수 있습니다.
AzureOpenAIClient openAIClient = new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential());
비고
GitHub의 Azure AI Speech SDK 리포지토리에서 wikipediaOcelot.wav 같은 샘플 오디오 파일을 가져올 수 있습니다.
빠른 시작을 실행하려면 다음 단계를 수행합니다.
내용을
Program.cs다음 코드로 바꾸고 자리 표시자 값을 사용자 고유의 값으로 업데이트합니다.using Azure; using Azure.AI.OpenAI; using Azure.Identity; // Required for Passwordless auth string deploymentName = "whisper"; string endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? "https://<your-resource-name>.openai.azure.com/"; string key = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY") ?? "<your-key>"; // Use the recommended keyless credential instead of the AzureKeyCredential credential. AzureOpenAIClient openAIClient = new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential()); //AzureOpenAIClient openAIClient = new AzureOpenAIClient(new Uri(endpoint), new AzureKeyCredential(key)); var audioFilePath = "<audio file path>" var audioClient = openAIClient.GetAudioClient(deploymentName); var result = await audioClient.TranscribeAudioAsync(audioFilePath); Console.WriteLine("Transcribed text:"); foreach (var item in result.Value.Text) { Console.Write(item); }Visual Studio 맨 위에 있는
dotnet run명령 또는 실행 단추를 사용하여 애플리케이션을 실행합니다.dotnet run
출력
샘플 오디오 파일을 사용하는 경우 콘솔에 인쇄된 다음 텍스트가 표시됩니다.
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...
필수 조건
- Azure 구독 - 무료로 생성하기
- Node.js의 LTS 버전
- 로컬 개발 환경에서 암호 없는 인증에 사용되는 Azure CLI는 Azure CLI로 로그인하여 필요한 컨텍스트를 만듭니다.
- 지원되는 지역에 배포된 음성 텍스트 변환 모델이 있는 Azure OpenAI 리소스입니다. 자세한 내용은 Azure OpenAI를 사용하여 리소스 만들기 및 모델 배포를 참조하세요.
Microsoft Entra ID 필수 구성 요소
Microsoft Entra ID를 사용하는 권장 키 없는 인증의 경우 다음을 수행해야 합니다.
- Microsoft Entra ID를 사용하여 키 없는 인증에 사용되는 Azure CLI 를 설치합니다.
- 사용자 계정에
Cognitive Services User역할을 할당합니다. Azure Portal의 액세스 제어(IAM)할 수 있습니다.
설정
새 폴더
synthesis-quickstart를 만들고 다음 명령을 사용하여 빠른 시작 폴더로 이동합니다.mkdir synthesis-quickstart && cd synthesis-quickstart다음 명령을 사용하여
package.json만듭니다.npm init -y다음을 사용하여 JavaScript용 OpenAI 클라이언트 라이브러리를 설치합니다.
npm install openai권장하는 암호 없는 인증의 경우:
npm install @azure/identity
리소스 정보 검색
Azure OpenAI 리소스를 사용하여 애플리케이션을 인증하려면 다음 정보를 검색해야 합니다.
| 변수 이름 | 가치 |
|---|---|
AZURE_OPENAI_ENDPOINT |
이 값은 Azure Portal에서 리소스를 검사할 때 키 및 엔드포인트 섹션에서 찾을 수 있습니다. |
AZURE_OPENAI_DEPLOYMENT_NAME |
이 값은 모델을 배포할 때 배포에 대해 선택한 사용자 지정 이름에 해당합니다. 이 값은 Azure Portal의 리소스 관리>에서 찾을 수 있습니다. |
OPENAI_API_VERSION |
API 버전에 대해 자세히 알아봅니다. 코드에서 버전을 변경하거나 환경 변수를 사용할 수 있습니다. |
주의
SDK에서 권장되는 키 없는 인증을 사용하려면 환경 변수가 AZURE_OPENAI_API_KEY 설정되지 않았는지 확인합니다.
샘플 애플리케이션 만들기
다음 코드를 사용하여
index.js파일을 만듭니다.const { createReadStream } = require("fs"); const { AzureOpenAI } = require("openai"); const { DefaultAzureCredential, getBearerTokenProvider } = require("@azure/identity"); // You will need to set these environment variables or edit the following values const audioFilePath = "<audio file path>"; const endpoint = process.env.AZURE_OPENAI_ENDPOINT || "Your endpoint"; // Required Azure OpenAI deployment name and API version const apiVersion = process.env.OPENAI_API_VERSION || "2024-08-01-preview"; const deploymentName = process.env.AZURE_OPENAI_DEPLOYMENT_NAME || "whisper"; // keyless authentication const credential = new DefaultAzureCredential(); const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(credential, scope); function getClient() { return new AzureOpenAI({ endpoint, azureADTokenProvider, apiVersion, deployment: deploymentName, }); } export async function main() { console.log("== Transcribe Audio Sample =="); const client = getClient(); const result = await client.audio.transcriptions.create({ model: "", file: createReadStream(audioFilePath), }); console.log(`Transcription: ${result.text}`); } main().catch((err) => { console.error("The sample encountered an error:", err); });다음 명령을 사용하여 Azure에 로그인합니다.
az loginJavaScript 파일을 실행합니다.
node index.js
GitHub의 Azure AI Speech SDK 리포지토리에서 wikipediaOcelot.wav 같은 샘플 오디오 파일을 가져올 수 있습니다.
출력
{"text":"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."}
필수 조건
- Azure 구독 - 무료로 생성하기
- Node.js의 LTS 버전
- TypeScript
- 로컬 개발 환경에서 암호 없는 인증에 사용되는 Azure CLI는 Azure CLI로 로그인하여 필요한 컨텍스트를 만듭니다.
- 지원되는 지역에 배포된 음성 텍스트 변환 모델이 있는 Azure OpenAI 리소스입니다. 자세한 내용은 Azure OpenAI를 사용하여 리소스 만들기 및 모델 배포를 참조하세요.
Microsoft Entra ID 필수 구성 요소
Microsoft Entra ID를 사용하는 권장 키 없는 인증의 경우 다음을 수행해야 합니다.
- Microsoft Entra ID를 사용하여 키 없는 인증에 사용되는 Azure CLI 를 설치합니다.
- 사용자 계정에
Cognitive Services User역할을 할당합니다. Azure Portal의 액세스 제어(IAM)할 수 있습니다.
설정
새 폴더
whisper-quickstart를 만들고 다음 명령을 사용하여 빠른 시작 폴더로 이동합니다.mkdir whisper-quickstart && cd whisper-quickstart다음 명령을 사용하여
package.json만듭니다.npm init -ypackage.json다음 명령을 사용하여 ECMAScript로 업데이트합니다.npm pkg set type=module다음을 사용하여 JavaScript용 OpenAI 클라이언트 라이브러리를 설치합니다.
npm install openai권장하는 암호 없는 인증의 경우:
npm install @azure/identity
리소스 정보 검색
Azure OpenAI 리소스를 사용하여 애플리케이션을 인증하려면 다음 정보를 검색해야 합니다.
| 변수 이름 | 가치 |
|---|---|
AZURE_OPENAI_ENDPOINT |
이 값은 Azure Portal에서 리소스를 검사할 때 키 및 엔드포인트 섹션에서 찾을 수 있습니다. |
AZURE_OPENAI_DEPLOYMENT_NAME |
이 값은 모델을 배포할 때 배포에 대해 선택한 사용자 지정 이름에 해당합니다. 이 값은 Azure Portal의 리소스 관리>에서 찾을 수 있습니다. |
OPENAI_API_VERSION |
API 버전에 대해 자세히 알아봅니다. 코드에서 버전을 변경하거나 환경 변수를 사용할 수 있습니다. |
주의
SDK에서 권장되는 키 없는 인증을 사용하려면 환경 변수가 AZURE_OPENAI_API_KEY 설정되지 않았는지 확인합니다.
샘플 애플리케이션 만들기
다음 코드를 사용하여
index.ts파일을 만듭니다.import { createReadStream } from "fs"; import { AzureOpenAI } from "openai"; import { DefaultAzureCredential, getBearerTokenProvider } from "@azure/identity"; // You will need to set these environment variables or edit the following values const audioFilePath = "<audio file path>"; const endpoint = process.env.AZURE_OPENAI_ENDPOINT || "Your endpoint"; // Required Azure OpenAI deployment name and API version const apiVersion = process.env.OPENAI_API_VERSION || "2024-08-01-preview"; const deploymentName = process.env.AZURE_OPENAI_DEPLOYMENT_NAME || "whisper"; // keyless authentication const credential = new DefaultAzureCredential(); const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(credential, scope); function getClient(): AzureOpenAI { return new AzureOpenAI({ endpoint, azureADTokenProvider, apiVersion, deployment: deploymentName, }); } export async function main() { console.log("== Transcribe Audio Sample =="); const client = getClient(); const result = await client.audio.transcriptions.create({ model: "", file: createReadStream(audioFilePath), }); console.log(`Transcription: ${result.text}`); } main().catch((err) => { console.error("The sample encountered an error:", err); });tsconfig.jsonTypeScript 코드를 전환하기 위한 파일을 만들고, ECMAScript용으로 다음 코드를 복사하세요.{ "compilerOptions": { "module": "NodeNext", "target": "ES2022", // Supports top-level await "moduleResolution": "NodeNext", "skipLibCheck": true, // Avoid type errors from node_modules "strict": true // Enable strict type-checking options }, "include": ["*.ts"] }TypeScript에서 JavaScript로 변환합니다.
tsc다음 명령을 사용하여 Azure에 로그인합니다.
az login다음 명령을 사용하여 코드를 실행합니다.
node index.js
GitHub의 Azure AI Speech SDK 리포지토리에서 wikipediaOcelot.wav 같은 샘플 오디오 파일을 가져올 수 있습니다.
중요합니다
주의해서 API 키를 사용합니다. API 키를 코드에 직접 포함하지 말고, 공개적으로 게시하지 마세요. API 키를 사용하는 경우 Azure Key Vault에 안전하게 저장합니다. 앱에서 API 키를 안전하게 사용하는 방법에 대한 자세한 내용은 Azure Key Vault를 사용하여 API 키를 참조하세요.
AI 서비스 보안에 대한 자세한 내용은 Azure AI 서비스에 대한 요청 인증을 참조하세요.
출력
{"text":"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."}
필수 조건
- Azure 구독 - 무료로 생성하기
- 최신 버전인 PowerShell 7 또는 Windows PowerShell 5.1을 사용할 수 있습니다.
- 지원되는 지역에 배포된 음성 텍스트 변환 모델이 있는 Azure OpenAI 리소스입니다. 자세한 내용은 Azure OpenAI를 사용하여 리소스 만들기 및 모델 배포를 참조하세요.
설정
키 및 엔드포인트 검색
Azure OpenAI에 대해 성공적으로 호출하려면 엔드포인트와 키가 필요합니다.
| 변수 이름 | 가치 |
|---|---|
AZURE_OPENAI_ENDPOINT |
서비스 엔드포인트는 Azure Portal에서 리소스를 검사할 때 키 및 엔드포인트 섹션에서 찾을 수 있습니다. 또는 Azure AI Foundry 포털의 배포 페이지를 통해 엔드포인트를 찾을 수 있습니다. 예제 엔드포인트는 https://docs-test-001.openai.azure.com/입니다. |
AZURE_OPENAI_API_KEY |
이 값은 Azure Portal에서 리소스를 검사할 때 키 및 엔드포인트 섹션에서 찾을 수 있습니다.
KEY1 또는 KEY2를 사용할 수 있습니다. |
Azure Portal에서 해당 리소스로 이동합니다.
엔드포인트 및 키는 리소스 관리 섹션에서 찾을 수 있습니다. 엔드포인트 및 액세스 키를 복사합니다. API 호출을 인증하는 데 모두 필요합니다.
KEY1 또는 KEY2를 사용할 수 있습니다. 항상 두 개의 키를 사용하면 서비스 중단 없이 키를 안전하게 회전하고 다시 생성할 수 있습니다.
환경 변수
키 및 엔드포인트에 대한 영구 환경 변수를 만들고 할당합니다.
중요합니다
주의해서 API 키를 사용합니다. API 키를 코드에 직접 포함하지 말고, 공개적으로 게시하지 마세요. API 키를 사용하는 경우 Azure Key Vault에 안전하게 저장합니다. 앱에서 API 키를 안전하게 사용하는 방법에 대한 자세한 내용은 Azure Key Vault를 사용하여 API 키를 참조하세요.
AI 서비스 보안에 대한 자세한 내용은 Azure AI 서비스에 대한 요청 인증을 참조하세요.
setx AZURE_OPENAI_API_KEY "REPLACE_WITH_YOUR_KEY_VALUE_HERE"
setx AZURE_OPENAI_ENDPOINT "REPLACE_WITH_YOUR_ENDPOINT_HERE"
PowerShell 앱 만들기
다음 명령을 실행합니다. Whisper 모델을 배포할 때 YourDeploymentName을 선택한 배포 이름으로 바꿔야 합니다. 배포 이름이 모델 이름과 반드시 똑같지는 않습니다. 기본 모델 이름과 동일한 배포 이름을 선택하지 않으면 모델 이름을 입력하면 오류가 발생합니다.
# Azure OpenAI metadata variables
$openai = @{
api_key = $Env:AZURE_OPENAI_API_KEY
api_base = $Env:AZURE_OPENAI_ENDPOINT # your endpoint should look like the following https://YOUR_RESOURCE_NAME.openai.azure.com/
api_version = '2024-02-01' # this may change in the future
name = 'YourDeploymentName' #This will correspond to the custom name you chose for your deployment when you deployed a model.
}
# Header for authentication
$headers = [ordered]@{
'api-key' = $openai.api_key
}
$form = @{ file = get-item -path './wikipediaOcelot.wav' }
# Send a completion call to generate an answer
$url = "$($openai.api_base)/openai/deployments/$($openai.name)/audio/transcriptions?api-version=$($openai.api_version)"
$response = Invoke-RestMethod -Uri $url -Headers $headers -Form $form -Method Post -ContentType 'multipart/form-data'
return $response.text
GitHub의 Azure AI Speech SDK 리포지토리에서 wikipediaOcelot.wav 같은 샘플 오디오 파일을 가져올 수 있습니다.
중요합니다
프로덕션의 경우 Azure Key Vault를 사용하는 PowerShell 비밀 관리와 같은 안전한 방법을 사용하여 자격 증명을 저장하고 액세스합니다. 자세한 내용은 자격 증명 보안을 참조하세요.
출력
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.
자원을 정리하세요
Azure OpenAI 리소스를 정리하고 제거하려면 해당 리소스를 삭제할 수 있습니다. 리소스를 삭제하기 전에 먼저 배포된 모델을 삭제해야 합니다.
다음 단계
- 오디오 데이터를 일괄 처리로 텍스트로 변환하는 방법을 알아보려면 일괄 처리 대화 내용 기록 만들기를 참조하세요.
- 더 많은 예제를 보려면 Azure OpenAI 샘플 GitHub 리포지토리를 확인하세요.