style
This commit is contained in:
parent
167b1849f0
commit
e17c3d1ef9
10 changed files with 64 additions and 30 deletions
|
|
@ -102,7 +102,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
try {
|
||||
const example = await fetch(instance.hfexampleAudioURL || '');
|
||||
exampleAudio = await example.blob();
|
||||
} catch {
|
||||
} catch (e) {
|
||||
throw new ApiError(meta.errors.unavailable);
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
try {
|
||||
app = await Client.connect(instance.hfSpaceName, { hf_token: instance.hfAuthKey });
|
||||
} catch {
|
||||
} catch (e) {
|
||||
throw new ApiError(meta.errors.unavailable);
|
||||
}
|
||||
|
||||
|
|
@ -135,19 +135,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
instance.hfdas,
|
||||
]);
|
||||
} catch (e) {
|
||||
console.error("An error occurred during prediction:", e);
|
||||
|
||||
const responseMessage = (e as any).message || ((e as any).original_msg && (e as any).original_msg.message);
|
||||
|
||||
if (responseMessage && responseMessage.includes('You have exceeded your GPU quota')) {
|
||||
outofQuota = true;
|
||||
console.log("Fallback to Inference API");
|
||||
console.info("Fallback to Inference API");
|
||||
notcontinue = true;
|
||||
} else {
|
||||
throw new ApiError(meta.errors.unavailable);
|
||||
}
|
||||
notcontinue = true;
|
||||
}
|
||||
|
||||
if (!notcontinue) {
|
||||
let resurl = result.data[0].url;
|
||||
const resurl = result.data[0].url;
|
||||
|
||||
const res = await this.httpRequestService.send(resurl, {
|
||||
method: 'GET',
|
||||
|
|
@ -157,7 +157,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
timeout: 60000,
|
||||
});
|
||||
|
||||
let contentType = res.headers.get('Content-Type') || 'application/octet-stream';
|
||||
const contentType = res.headers.get('Content-Type') || 'application/octet-stream';
|
||||
|
||||
if (contentType === 'audio/x-wav') {
|
||||
return res.body;
|
||||
|
|
@ -183,7 +183,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
timeout: 60000,
|
||||
});
|
||||
|
||||
let contentType = res.headers.get('Content-Type') || 'application/octet-stream';
|
||||
const contentType = res.headers.get('Content-Type') || 'application/octet-stream';
|
||||
|
||||
if (contentType === 'audio/flac') {
|
||||
return res.body;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue