Answer the question
In order to leave comments, you need to log in
The request to the SpeechKIT API is not working (401) - where is the error?
Good afternoon, a request to Yandex.Api through the Browser returns an authorization error 401 :
although the similar code for NodeJS works.
I can't figure out what salt is.
Yandex documentation: description of the API method
My Code:
let api_key = '**********mySecretCode**********************';
let params = new URLSearchParams();
const text = 'Привет!';
params.append('text', text);
params.append('voice', 'jane');
params.append('emotion', 'good');
params.append('lang', 'ru-RU');
params.append('speed', '1.0');
params.append('format', 'oggopus');
//================ кнопочка запроса ===================================
const fetchButton = document.getElementById("fetchButton");
fetchButton.onclick = ()=> {
fetch('https://tts.api.cloud.yandex.net/speech/v1/tts:synthesize', {
method: 'POST',
body: params,
mode: "no-cors", //иначе ругается
headers: {
//'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Api-Key ' + api_key,
},
})
.then(res => {
console.log(`responce is ${res}`);
// return res.json();
//const dest = fs.createWriteStream('./octocat2.ogg');
//res.body.pipe(dest);
})
.catch(err => console.error(`!!! + ${err} + !!!!!!!!`));
}
Answer the question
In order to leave comments, you need to log in
It's hard to answer, as I understand it, you log in using a service account, maybe you forgot to assign a role? https://cloud.yandex.ru/docs/iam/operations/sa/ass... of
course, I could not go further, I did not create a paid account.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question