@@ -160,7 +160,7 @@ public <T> ResponseEntity<T> createTranscription(TranscriptionRequest requestBod
160
160
161
161
@ Override
162
162
public String getFilename () {
163
- return "audio.webm" ;
163
+ return requestBody . fileName () ;
164
164
}
165
165
});
166
166
multipartBody .add ("model" , requestBody .model ());
@@ -206,7 +206,7 @@ public <T> ResponseEntity<T> createTranslation(TranslationRequest requestBody, C
206
206
207
207
@ Override
208
208
public String getFilename () {
209
- return "audio.webm" ;
209
+ return requestBody . fileName () ;
210
210
}
211
211
});
212
212
multipartBody .add ("model" , requestBody .model ());
@@ -496,6 +496,7 @@ public SpeechRequest build() {
496
496
* Transcription</a>
497
497
*
498
498
* @param file The audio file to transcribe. Must be a valid audio file type.
499
+ * @param fileName The audio file name.
499
500
* @param model ID of the model to use. Only whisper-1 is currently available.
500
501
* @param language The language of the input audio. Supplying the input language in
501
502
* ISO-639-1 format will improve accuracy and latency.
@@ -517,6 +518,7 @@ public SpeechRequest build() {
517
518
public record TranscriptionRequest (
518
519
// @formatter:off
519
520
@ JsonProperty ("file" ) byte [] file ,
521
+ @ JsonProperty ("fileName" ) String fileName ,
520
522
@ JsonProperty ("model" ) String model ,
521
523
@ JsonProperty ("language" ) String language ,
522
524
@ JsonProperty ("prompt" ) String prompt ,
@@ -554,6 +556,8 @@ public static class Builder {
554
556
555
557
private byte [] file ;
556
558
559
+ private String fileName ;
560
+
557
561
private String model = WhisperModel .WHISPER_1 .getValue ();
558
562
559
563
private String language ;
@@ -571,6 +575,11 @@ public Builder file(byte[] file) {
571
575
return this ;
572
576
}
573
577
578
+ public Builder fileName (String fileName ) {
579
+ this .fileName = fileName ;
580
+ return this ;
581
+ }
582
+
574
583
public Builder model (String model ) {
575
584
this .model = model ;
576
585
return this ;
@@ -603,11 +612,12 @@ public Builder granularityType(GranularityType granularityType) {
603
612
604
613
public TranscriptionRequest build () {
605
614
Assert .notNull (this .file , "file must not be null" );
615
+ Assert .notNull (this .fileName , "fileName must not be null" );
606
616
Assert .hasText (this .model , "model must not be empty" );
607
617
Assert .notNull (this .responseFormat , "response_format must not be null" );
608
618
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 );
611
621
}
612
622
613
623
}
@@ -619,6 +629,7 @@ public TranscriptionRequest build() {
619
629
*
620
630
* @param file The audio file object (not file name) to translate, in one of these
621
631
* formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
632
+ * @param fileName The audio file name.
622
633
* @param model ID of the model to use. Only whisper-1 is currently available.
623
634
* @param prompt An optional text to guide the model's style or continue a previous
624
635
* audio segment. The prompt should be in English.
@@ -633,6 +644,7 @@ public TranscriptionRequest build() {
633
644
public record TranslationRequest (
634
645
// @formatter:off
635
646
@ JsonProperty ("file" ) byte [] file ,
647
+ @ JsonProperty ("fileName" ) String fileName ,
636
648
@ JsonProperty ("model" ) String model ,
637
649
@ JsonProperty ("prompt" ) String prompt ,
638
650
@ JsonProperty ("response_format" ) TranscriptResponseFormat responseFormat ,
@@ -647,6 +659,8 @@ public static class Builder {
647
659
648
660
private byte [] file ;
649
661
662
+ private String fileName ;
663
+
650
664
private String model = WhisperModel .WHISPER_1 .getValue ();
651
665
652
666
private String prompt ;
@@ -660,6 +674,11 @@ public Builder file(byte[] file) {
660
674
return this ;
661
675
}
662
676
677
+ public Builder fileName (String fileName ) {
678
+ this .fileName = fileName ;
679
+ return this ;
680
+ }
681
+
663
682
public Builder model (String model ) {
664
683
this .model = model ;
665
684
return this ;
@@ -685,7 +704,7 @@ public TranslationRequest build() {
685
704
Assert .hasText (this .model , "model must not be empty" );
686
705
Assert .notNull (this .responseFormat , "response_format must not be null" );
687
706
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 ,
689
708
this .temperature );
690
709
}
691
710
0 commit comments