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 class
MotorLargeTranscriptionRequest.Builder
Builder class forMotorSummaryRequest
. -
Method Summary
Modifier and Type Method Description String
aiModel()
Gets the AI model to be used in the request.static MotorLargeTranscriptionRequest.Builder
builder()
Returns a new builder instance for creating aMotorLargeTranscriptionRequest
.ChatMotor
chatMotor()
Gets the ChatMotor to be used in the request.MotorLargeResponse
execute()
Executes the transcription request and returns the response.String
filePath()
Gets the file path to be used in the request.ChunkSize
inputChunkSize()
Returns the input chunk sizeProgressListener
progressListener()
Gets the ProgressListener to be used in the request.boolean
timestampTranscript()
Gets whether or not to timestamp the transcript.
-
Method Details
-
builder
Returns a new builder instance for creating aMotorLargeTranscriptionRequest
.- Returns:
- a new
MotorLargeTranscriptionRequest
builder
-
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:
MotorLargeResponse
encapsulating the result of the transcription attempt.
-