audio endpoint, can you upload form data?
```
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);
}
}
```
I am trying this code and getting the following error
```
This is the data from the DID API: { kind: 'UnknownError', description: 'Internal Server Error' }
```
The audio is generated as follows
```
// response from some audio generating api
const audioBuffer = await response.arrayBuffer();
const audioBlob = new Blob([audioBuffer], { type: 'audio/mpeg' });
```
Posted by support 12 months ago