mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
🗣️ fix: Azure OpenAI STT (#3731)
* Fix for Azure OpenAI STT * chore(STTService): imports order --------- Co-authored-by: Danny Avila <danacordially@gmail.com>
This commit is contained in:
parent
7536e649d4
commit
63b80c3067
1 changed files with 7 additions and 9 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
const { Readable } = require('stream');
|
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const FormData = require('form-data');
|
||||||
|
const { Readable } = require('stream');
|
||||||
const { extractEnvVariable, STTProviders } = require('librechat-data-provider');
|
const { extractEnvVariable, STTProviders } = require('librechat-data-provider');
|
||||||
const getCustomConfig = require('~/server/services/Config/getCustomConfig');
|
const getCustomConfig = require('~/server/services/Config/getCustomConfig');
|
||||||
const { genAzureEndpoint } = require('~/utils');
|
const { genAzureEndpoint } = require('~/utils');
|
||||||
|
|
@ -136,8 +137,10 @@ class STTService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
const audioBlob = new Blob([audioBuffer], { type: audioFile.mimetype });
|
formData.append('file', audioBuffer, {
|
||||||
formData.append('file', audioBlob, audioFile.originalname);
|
filename: audioFile.originalname,
|
||||||
|
contentType: audioFile.mimetype,
|
||||||
|
});
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
|
|
@ -146,7 +149,7 @@ class STTService {
|
||||||
|
|
||||||
[headers].forEach(this.removeUndefined);
|
[headers].forEach(this.removeUndefined);
|
||||||
|
|
||||||
return [url, formData, headers];
|
return [url, formData, { ...headers, ...formData.getHeaders() }];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -171,11 +174,6 @@ class STTService {
|
||||||
|
|
||||||
const [url, data, headers] = strategy.call(this, sttSchema, audioReadStream, audioFile);
|
const [url, data, headers] = strategy.call(this, sttSchema, audioReadStream, audioFile);
|
||||||
|
|
||||||
if (!Readable.from && data instanceof FormData) {
|
|
||||||
const audioBlob = new Blob([audioBuffer], { type: audioFile.mimetype });
|
|
||||||
data.set('file', audioBlob, audioFile.originalname);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(url, data, { headers });
|
const response = await axios.post(url, data, { headers });
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue