Skip to content

Commit 63b80c3

Browse files
maxessedanny-avila
andauthored
🗣️ fix: Azure OpenAI STT (danny-avila#3731)
* Fix for Azure OpenAI STT * chore(STTService): imports order --------- Co-authored-by: Danny Avila <[email protected]>
1 parent 7536e64 commit 63b80c3

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

api/server/services/Files/Audio/STTService.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const { Readable } = require('stream');
21
const axios = require('axios');
2+
const FormData = require('form-data');
3+
const { Readable } = require('stream');
34
const { extractEnvVariable, STTProviders } = require('librechat-data-provider');
45
const getCustomConfig = require('~/server/services/Config/getCustomConfig');
56
const { genAzureEndpoint } = require('~/utils');
@@ -136,8 +137,10 @@ class STTService {
136137
}
137138

138139
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+
});
141144

142145
const headers = {
143146
'Content-Type': 'multipart/form-data',
@@ -146,7 +149,7 @@ class STTService {
146149

147150
[headers].forEach(this.removeUndefined);
148151

149-
return [url, formData, headers];
152+
return [url, formData, { ...headers, ...formData.getHeaders() }];
150153
}
151154

152155
/**
@@ -171,11 +174,6 @@ class STTService {
171174

172175
const [url, data, headers] = strategy.call(this, sttSchema, audioReadStream, audioFile);
173176

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-
179177
try {
180178
const response = await axios.post(url, data, { headers });
181179

0 commit comments

Comments
 (0)