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 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.

  • Method Details

    • builder

      public static MotorLargeTranscriptionRequest.Builder builder()
      Returns a new builder instance for creating a MotorLargeTranscriptionRequest.
      Returns:
      a new MotorLargeTranscriptionRequest builder
    • chatMotor

      public ChatMotor chatMotor()
      Gets the ChatMotor to be used in the request.
      Returns:
      the
    • aiModel

      public String aiModel()
      Gets the AI model to be used in the request.
      Returns:
      the AI model to be used in the request
    • filePath

      public String 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

      public ChunkSize inputChunkSize()
      Returns the input chunk size
      Returns:
      the input chunk size
    • progressListener

      public ProgressListener progressListener()
      Gets the ProgressListener to be used in the request.
      Returns:
      the ProgressListener instance
    • execute

      public MotorLargeResponse execute()
      Executes the transcription request and returns the response.
      Returns:
      MotorLargeResponse encapsulating the result of the transcription attempt.