Class MotorAudioFileConverter
java.lang.Object
com.chatmotorapi.api.transcription.MotorAudioFileConverter
public class MotorAudioFileConverter extends Object
The MotorAudioFileConverter class is responsible for converting audio files from one format to another.
This class ensures the input and output files are valid before performing the conversion. It supports all audio conversion formats available in FFmpeg.
Example Usage:
Note: Android platforms are not supported.
This class ensures the input and output files are valid before performing the conversion. It supports all audio conversion formats available in FFmpeg.
Example Usage:
// We assume that the env var MOTOR_API_KEY is set
// Create a ChatMotor instance.
ChatMotor chatMotor = ChatMotor.builder().build();
String audioFilePath = "/path/to/audio/file.wav";
// Build the audio file converter request.
MotorAudioFileConverter motorAudioFileConverter = MotorAudioFileConverter.builder()
.chatMotor(chatMotor)
.inputFilePath(audioFilePath)
.conversionFormat("MP4")
.build();
// Execute the conversion request.
MotorLargeResponse motorLargeResponse = motorAudioFileConverter.convert();
if (motorLargeResponse.isResponseOk()) {
String convertedFilePath = audioFilePath + ".mp4";
try (InputStream in = motorLargeResponse.getInputStream()) {
Files.copy(in, Paths.get(convertedFilePath), StandardCopyOption.REPLACE_EXISTING);
}
} else {
System.out.println("throwable : " + motorLargeResponse.getThrowable());
}
Note: Android platforms are not supported.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MotorAudioFileConverter.Builder
Builder class for creating a MotorAudioFileConverter instance. -
Method Summary
Modifier and Type Method Description static MotorAudioFileConverter.Builder
builder()
Static method to initiate building a MotorAudioFileConverter instance.ChatMotor
chatMotor()
Gets the ChatMotor to be used in the request.String
conversionFormat()
Returns the target conversion format.MotorLargeResponse
execute()
Converts the input audio file to the specified format.String
inputFilePath()
Returns the orignal audio file path.
-
Method Details
-
builder
Static method to initiate building a MotorAudioFileConverter instance.- Returns:
- a new Builder instance
-
chatMotor
Gets the ChatMotor to be used in the request.- Returns:
- the
-
inputFilePath
Returns the orignal audio file path.- Returns:
- the
-
conversionFormat
Returns the target conversion format.- Returns:
- the target conversion format
-
execute
Converts the input audio file to the specified format.- Returns:
- MotorLargeResponse encapsulating the result of the conversion attempt
-