export const uploadAudio = async (audio) => {
const formData = new FormData();
formData.append('audio', audio, 'audio.mp3');
try {
const response = await fetch(voicesURL, {
method: 'POST',
headers: {
'accept': 'application/json',
'authorization': 'Basic ' + didApiKey,
'content-type': 'multipart/form-data'
},
body: formData
});
const data = await response.json();
console.log("\x1b[46m\x1b[30m%s\x1b[0m", "This is the data from the DID API: ", data)
// Do something with the data, for instance send it as a response or process it
return data;
} catch (error) {
// Handle errors, for instance send an error response or log the error
console.error('Error fetching data:', error);
}
}