Spaces:
Running
Running
API Error
#64
by
dylan0356
- opened
Hello, I am currently getting this error when trying to submit a request. This even happens with the example audio MOST of the time.
{
type: 'status',
endpoint: '/predict_1',
fn_index: 3,
time: 2023-10-17T18:58:32.826Z,
queue: true,
message: null,
stage: 'error',
code: undefined,
success: false
}
async function whisperAPI (audioFile) {
const app = await client("https://sanchit-gandhi-whisper-jax.hf.space/");
const result = await app.predict("/predict_1", [
audioFile, // blob in 'inputs' Audio component
"transcribe", // string in 'Task' Radio component
true, // boolean in 'Return timestamps' Checkbox component
]);
console.log(result.data); // [ '[00:00.000 -> 00:00.840] Peace.', '4.890807151794434' ]
const transcript = result.data[0];
return transcript
}
async function transcribeAudio(filename) {
// This uses the Gradio API to transcribe the audio. It is free and fast but not working.
//Wants the audio file in the form of a blob
const response_0 = await fetch("https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav");
const exampleAudio = await response_0.blob();
const audioFile = new Blob([fileStream], { type: 'audio/ogg' });
//try a max of 10 times to get a response from the API before giving up
for (let i = 0; i < 10; i++) {
try {
const transcript = await whisperAPI(audioFile);
return transcript;
} catch (error) {
console.log("Error in transcription");
console.log(error);
}
}
}