Spaces:
Running
Running
Error transcribing audio
#49
by
Smoky5601
- opened
I am trying to call the predict_1
API endpoint from a node.js
(v18.17.0) application, however I keep getting the following error response:
{
type: 'status',
endpoint: '/predict_1',
fn_index: 3,
time: 2023-08-03T14:34:45.618Z,
queue: true,
message: null,
stage: 'error',
code: undefined,
success: false
}
How can I get more insight into why the transcription failed?
Here is my code:
import axios from 'axios';
import { client } from "@gradio/client";
import bufferToStream from 'buffer-to-stream';
let downloadResponse ;
let mp3Buffer ;
try {
downloadResponse = await axios.get(audioUrl, { responseType: 'arraybuffer' });
// Convert the arraybuffer to a Buffer
mp3Buffer = Buffer.from(downloadResponse.data);
console.log('MP3 file downloaded successfully!');
} catch(e) {
console.log('Error downloading mp3', e)
}
try {
const audioBlob = bufferToStream(mp3Buffer );
// const audioBlob = new Blob([audio], { type: 'audio/mp3' });
// NOTE: Trying to send as Blob results in error:
// undefined:1 <html> ^ SyntaxError: Unexpected token < in JSON at position 0
const app = await client("https://sanchit-gandhi-whisper-jax.hf.space/");
const result = await app.predict("/predict_1", [
audioBlob, // blob in 'Audio file' Audio component
"transcribe", // string in 'Task' Radio component
false, // boolean in 'Return timestamps' Checkbox component
]);
console.log(result?.data);
} catch(e) {
console.log('Error transcribing audio', e)
}
I have confirmed the audio is not corrupt, I can play the audio that is downloaded fine.
Might have been that the space was hanging previously - could you try again now please @Smoky5601 ? Thanks!
Hey @sanchit-gandhi , I am still getting the same error. I think this is unrelated to the hanging issue that happened recently.
{
type: 'status',
stage: 'error',
message: 'Connection errored out.',
queue: true,
endpoint: '/predict_1',
fn_index: 3,
time: 2023-08-08T04:35:24.546Z
}