@@ -160,7 +160,7 @@ public <T> ResponseEntity<T> createTranscription(TranscriptionRequest requestBod
160160
161161 @ Override
162162 public String getFilename () {
163- return "audio.webm" ;
163+ return requestBody . fileName () ;
164164 }
165165 });
166166 multipartBody .add ("model" , requestBody .model ());
@@ -206,7 +206,7 @@ public <T> ResponseEntity<T> createTranslation(TranslationRequest requestBody, C
206206
207207 @ Override
208208 public String getFilename () {
209- return "audio.webm" ;
209+ return requestBody . fileName () ;
210210 }
211211 });
212212 multipartBody .add ("model" , requestBody .model ());
@@ -496,6 +496,7 @@ public SpeechRequest build() {
496496 * Transcription</a>
497497 *
498498 * @param file The audio file to transcribe. Must be a valid audio file type.
499+ * @param fileName The audio file name.
499500 * @param model ID of the model to use. Only whisper-1 is currently available.
500501 * @param language The language of the input audio. Supplying the input language in
501502 * ISO-639-1 format will improve accuracy and latency.
@@ -517,6 +518,7 @@ public SpeechRequest build() {
517518 public record TranscriptionRequest (
518519 // @formatter:off
519520 @ JsonProperty ("file" ) byte [] file ,
521+ @ JsonProperty ("fileName" ) String fileName ,
520522 @ JsonProperty ("model" ) String model ,
521523 @ JsonProperty ("language" ) String language ,
522524 @ JsonProperty ("prompt" ) String prompt ,
@@ -554,6 +556,8 @@ public static class Builder {
554556
555557 private byte [] file ;
556558
559+ private String fileName ;
560+
557561 private String model = WhisperModel .WHISPER_1 .getValue ();
558562
559563 private String language ;
@@ -571,6 +575,11 @@ public Builder file(byte[] file) {
571575 return this ;
572576 }
573577
578+ public Builder fileName (String fileName ) {
579+ this .fileName = fileName ;
580+ return this ;
581+ }
582+
574583 public Builder model (String model ) {
575584 this .model = model ;
576585 return this ;
@@ -603,11 +612,12 @@ public Builder granularityType(GranularityType granularityType) {
603612
604613 public TranscriptionRequest build () {
605614 Assert .notNull (this .file , "file must not be null" );
615+ Assert .notNull (this .fileName , "fileName must not be null" );
606616 Assert .hasText (this .model , "model must not be empty" );
607617 Assert .notNull (this .responseFormat , "response_format must not be null" );
608618
609- return new TranscriptionRequest (this .file , this .model , this .language , this .prompt , this .responseFormat ,
610- this .temperature , this .granularityType );
619+ return new TranscriptionRequest (this .file , this .fileName , this .model , this .language , this .prompt ,
620+ this .responseFormat , this . temperature , this .granularityType );
611621 }
612622
613623 }
@@ -619,6 +629,7 @@ public TranscriptionRequest build() {
619629 *
620630 * @param file The audio file object (not file name) to translate, in one of these
621631 * formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
632+ * @param fileName The audio file name.
622633 * @param model ID of the model to use. Only whisper-1 is currently available.
623634 * @param prompt An optional text to guide the model's style or continue a previous
624635 * audio segment. The prompt should be in English.
@@ -633,6 +644,7 @@ public TranscriptionRequest build() {
633644 public record TranslationRequest (
634645 // @formatter:off
635646 @ JsonProperty ("file" ) byte [] file ,
647+ @ JsonProperty ("fileName" ) String fileName ,
636648 @ JsonProperty ("model" ) String model ,
637649 @ JsonProperty ("prompt" ) String prompt ,
638650 @ JsonProperty ("response_format" ) TranscriptResponseFormat responseFormat ,
@@ -647,6 +659,8 @@ public static class Builder {
647659
648660 private byte [] file ;
649661
662+ private String fileName ;
663+
650664 private String model = WhisperModel .WHISPER_1 .getValue ();
651665
652666 private String prompt ;
@@ -660,6 +674,11 @@ public Builder file(byte[] file) {
660674 return this ;
661675 }
662676
677+ public Builder fileName (String fileName ) {
678+ this .fileName = fileName ;
679+ return this ;
680+ }
681+
663682 public Builder model (String model ) {
664683 this .model = model ;
665684 return this ;
@@ -685,7 +704,7 @@ public TranslationRequest build() {
685704 Assert .hasText (this .model , "model must not be empty" );
686705 Assert .notNull (this .responseFormat , "response_format must not be null" );
687706
688- return new TranslationRequest (this .file , this .model , this .prompt , this .responseFormat ,
707+ return new TranslationRequest (this .file , this .fileName , this . model , this .prompt , this .responseFormat ,
689708 this .temperature );
690709 }
691710
0 commit comments