Nodejsda kelgan responseni ya'ni .ogg fileni qanday qilib saqlab olish mumkin ? #3
Unanswered
abduraimovabdurahmon
asked this question in
Savol va Javoblar
Replies: 1 comment
-
Assalomu alaykum. Siz const axios = require('axios');
const fs = require('fs');
let token = '**************************************';
let text_input = 'Salom dunyo!';
let speaker_id = 1;
console.log("Token: ", token);
let config = {
method: 'post',
url: 'https://api.muxlisa.uz/v1/api/services/tts/',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: {
token: token,
text: text_input,
speaker_id: speaker_id
},
responseType: 'arraybuffer' // Ensure response is treated as binary data
};
async function fetchAudio() {
try {
const response = await axios.request(config)
if (response.status !== 200) {
console.error("Error fetching audio:", response.statusText);
return;
}
let audio = response.data;
fs.writeFileSync('audio.ogg', audio);
} catch (error) {
console.error("Error fetching audio:", error);
}
}
fetchAudio(); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Meni kodim:
lekin bu nimagadir ishlamayapti.
Beta Was this translation helpful? Give feedback.
All reactions