1
- const { Readable } = require ( 'stream' ) ;
2
1
const axios = require ( 'axios' ) ;
2
+ const FormData = require ( 'form-data' ) ;
3
+ const { Readable } = require ( 'stream' ) ;
3
4
const { extractEnvVariable, STTProviders } = require ( 'librechat-data-provider' ) ;
4
5
const getCustomConfig = require ( '~/server/services/Config/getCustomConfig' ) ;
5
6
const { genAzureEndpoint } = require ( '~/utils' ) ;
@@ -136,8 +137,10 @@ class STTService {
136
137
}
137
138
138
139
const formData = new FormData ( ) ;
139
- const audioBlob = new Blob ( [ audioBuffer ] , { type : audioFile . mimetype } ) ;
140
- formData . append ( 'file' , audioBlob , audioFile . originalname ) ;
140
+ formData . append ( 'file' , audioBuffer , {
141
+ filename : audioFile . originalname ,
142
+ contentType : audioFile . mimetype ,
143
+ } ) ;
141
144
142
145
const headers = {
143
146
'Content-Type' : 'multipart/form-data' ,
@@ -146,7 +149,7 @@ class STTService {
146
149
147
150
[ headers ] . forEach ( this . removeUndefined ) ;
148
151
149
- return [ url , formData , headers ] ;
152
+ return [ url , formData , { ... headers , ... formData . getHeaders ( ) } ] ;
150
153
}
151
154
152
155
/**
@@ -171,11 +174,6 @@ class STTService {
171
174
172
175
const [ url , data , headers ] = strategy . call ( this , sttSchema , audioReadStream , audioFile ) ;
173
176
174
- if ( ! Readable . from && data instanceof FormData ) {
175
- const audioBlob = new Blob ( [ audioBuffer ] , { type : audioFile . mimetype } ) ;
176
- data . set ( 'file' , audioBlob , audioFile . originalname ) ;
177
- }
178
-
179
177
try {
180
178
const response = await axios . post ( url , data , { headers } ) ;
181
179
0 commit comments