Class MotorLargeTranscriptionRequest
java.lang.Object
com.chatmotorapi.api.transcription.MotorLargeTranscriptionRequest
public class MotorLargeTranscriptionRequest extends Object
Handles the creation and execution of transcription requests using the
You can add a ProgressListener to the request to track progress using
Note that on Android, the file passed to
ChatMotor API. This class is designed to transcribe audio files into
text using OpenAI's Whisper model configured through the ChatMotor.
The model to be used in requests can be
specified with the .aiModel setter directly on the MotorLargeTranscriptionRequest
builder. If .aiModel is not called, the default model used is
System.getenv("MOTOR_WHISPER_MODEL"). If the environment variable is not set,
the model used is MotorDefaultsModels.MOTOR_WHISPER_MODEL. You can add a ProgressListener to the request to track progress using
.progressListener(ProgressListener progressListener).
See the User Guide for more info.
Note that on Android, the file passed to
MotorLargeTranscriptionRequest.builder().filePath(String filePath) must be
a MP3 file.
Usage example:
String audioFilePath = "/path/to/my_audiofile.wav";
String transcriptionFile = "transcription_file.txt";
// We assume that the env var MOTOR_API_KEY is set.
ChatMotor chatMotor = ChatMotor.builder()
.build();
MotorLargeTranscriptionRequest transcriptionRequest = MotorLargeTranscriptionRequest.builder()
.chatMotor(chatMotor)
.filePath(audioFilePath)
.build();
MotorLargeResponse largeResponse = transcriptionRequest.execute();
if (largeResponse.isResponseOk()) {
try (InputStream in = largeResponse.getInputStream()) {
Files.copy(in, Paths.get(transcriptionFilePath), StandardCopyOption.REPLACE_EXISTING);
}
} else {
// Treat MotorLargeResponse
// See the MotorResponse class for more details.
}
This class uses a builder pattern to ensure a flexible and secure way to configure each transcription request.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMotorLargeTranscriptionRequest.BuilderBuilder class forMotorSummaryRequest. -
Method Summary
Modifier and Type Method Description StringaiModel()Gets the AI model to be used in the request.static MotorLargeTranscriptionRequest.Builderbuilder()Returns a new builder instance for creating aMotorLargeTranscriptionRequest.ChatMotorchatMotor()Gets the ChatMotor to be used in the request.MotorLargeResponseexecute()Executes the transcription request and returns the response.StringfilePath()Gets the file path to be used in the request.ChunkSizeinputChunkSize()Returns the input chunk sizeProgressListenerprogressListener()Gets the ProgressListener to be used in the request.booleantimestampTranscript()Gets whether or not to timestamp the transcript.
-
Method Details
-
builder
Returns a new builder instance for creating aMotorLargeTranscriptionRequest.- Returns:
- a new
MotorLargeTranscriptionRequestbuilder
-
chatMotor
Gets the ChatMotor to be used in the request.- Returns:
- the
-
aiModel
Gets the AI model to be used in the request.- Returns:
- the AI model to be used in the request
-
filePath
Gets the file path to be used in the request.- Returns:
- the file path to be used in the request
-
timestampTranscript
public boolean timestampTranscript()Gets whether or not to timestamp the transcript.- Returns:
- whether or not to timestamp the transcript
-
inputChunkSize
Returns the input chunk size- Returns:
- the input chunk size
-
progressListener
Gets the ProgressListener to be used in the request.- Returns:
- the ProgressListener instance
-
execute
Executes the transcription request and returns the response.- Returns:
MotorLargeResponseencapsulating the result of the transcription attempt.
-