n8n-nodes-salutespeech
Version:
User-friendly SaluteSpeech (Sber) community node
43 lines • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.post_speech_recognize = post_speech_recognize;
const utils_1 = require("./utils");
const exception_1 = require("./exception");
function getRequestConfig({ file, language = 'ru-RU', profanity = true, model = 'general', sampleRate = 16000, channelsCount = 1, accessToken, }) {
const headers = { ...(0, utils_1.buildHeaders)(accessToken), 'Content-Type': file.type };
const query = {
language,
enable_profanity_filter: profanity,
model,
sample_rate: sampleRate,
channels_count: channelsCount,
};
return {
method: 'POST',
url: '/speech:recognize',
data: file,
params: query,
headers: headers,
};
}
function buildResponse(response) {
if (response.status === 200) {
return response.data;
}
else if (response.status === 401) {
console.error(response.data);
throw new exception_1.AuthenticationError(response);
}
else {
console.error(response.data);
throw new exception_1.ResponseError(response);
}
}
async function post_speech_recognize(client, args) {
const config = getRequestConfig(args);
console.log('post_speech_recognize.config', config);
const response = await client.request(config);
console.log('post_speech_recognize.response', response);
return buildResponse(response).result || [];
}
//# sourceMappingURL=PostSpeechRecognize.js.map