Class AzureOpenAiAudioTranscriptionModel
java.lang.Object
dev.langchain4j.model.azure.AzureOpenAiAudioTranscriptionModel
- All Implemented Interfaces:
AudioTranscriptionModel
@Experimental
public class AzureOpenAiAudioTranscriptionModel
extends Object
implements AudioTranscriptionModel
Represents an Azure OpenAI audio transcription model, such as Whisper.
You can find a tutorial on using Azure OpenAI for speech to text at: https://learn.microsoft.com/azure/ai-services/openai/whisper-quickstart
Mandatory parameters for initialization are:
- endpoint: The Azure OpenAI endpoint URL
- authentication: Either apiKey, tokenCredential (Azure Active Directory), or an existing OpenAIClient
- deploymentName: The name of your Azure OpenAI audio model deployment
There are 3 authentication methods:
- Azure OpenAI API Key: The most common method using an Azure OpenAI API key.
Use the
apiKey()method in the Builder. - Non-Azure OpenAI API Key: Use the OpenAI service directly (not Azure OpenAI).
Use the
nonAzureApiKey()method, which will automatically set the endpoint. - Microsoft Entra ID (Azure Active Directory): Authenticate using Azure credentials.
Requires the
com.azure:azure-identitydependency. Use thetokenCredential()method with an appropriate credential implementation likeDefaultAzureCredential.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionAzureOpenAiAudioTranscriptionModel(com.azure.ai.openai.OpenAIClient client, String deploymentName, com.azure.ai.openai.models.AudioTranscriptionFormat responseFormat) Creates a new AzureOpenAiAudioTranscriptionModel with the provided client and parameters.Creates a new AzureOpenAiAudioTranscriptionModel using the provided builder. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a new builder for AzureOpenAiAudioTranscriptionModel.transcribe(AudioTranscriptionRequest request) Given an audio file, generates a transcription.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AudioTranscriptionModel
transcribeToText
-
Constructor Details
-
AzureOpenAiAudioTranscriptionModel
Creates a new AzureOpenAiAudioTranscriptionModel using the provided builder. This is the recommended constructor for future compatibility.- Parameters:
builder- The builder containing all the configuration
-
AzureOpenAiAudioTranscriptionModel
public AzureOpenAiAudioTranscriptionModel(com.azure.ai.openai.OpenAIClient client, String deploymentName, com.azure.ai.openai.models.AudioTranscriptionFormat responseFormat) Creates a new AzureOpenAiAudioTranscriptionModel with the provided client and parameters. Use the builder for more convenient construction.- Parameters:
client- The Azure OpenAI clientdeploymentName- The deployment name of the audio modelresponseFormat- The response format (can be null for default JSON format)
-
-
Method Details
-
transcribe
Description copied from interface:AudioTranscriptionModelGiven an audio file, generates a transcription.- Specified by:
transcribein interfaceAudioTranscriptionModel- Parameters:
request- The transcription request containing the audio file and optional parameters- Returns:
- The generated transcription response
-
builder
Creates a new builder for AzureOpenAiAudioTranscriptionModel.- Returns:
- A new builder instance
-