Skip to content

Commit

Permalink
reject promise for transcribe error
Browse files Browse the repository at this point in the history
  • Loading branch information
elorzafe committed Jul 31, 2019
1 parent 122b12d commit 93f10c7
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ export default class AmazonAIConvertPredictionsProvider extends AbstractConvertP
const connection
= await this.openConnectionWithTranscribe({ credentials, region, languageCode: language });

const fullText = await this.sendDataToTranscribe({ connection, raw: source.bytes });
return res({
transcription: {
fullText,
}
});
try {
const fullText = await this.sendDataToTranscribe({ connection, raw: source.bytes });
return res({
transcription: {
fullText,
}
});
} catch (err) {
rej(err.message);
}
}

return rej("Source types other than byte source are not supported.");
Expand All @@ -150,6 +154,7 @@ export default class AmazonAIConvertPredictionsProvider extends AbstractConvertP
const transcribeMessageJson = JSON.parse(String.fromCharCode.apply(String, transcribeMessage.body));
if (transcribeMessage.headers[":message-type"].value === "exception") {
logger.debug('exception', JSON.stringify(transcribeMessageJson.Message, null, 2));
throw new Error(transcribeMessageJson.Message);
}
else if (transcribeMessage.headers[":message-type"].value === "event") {
if (transcribeMessageJson.Transcript.Results.length > 0) {
Expand Down

0 comments on commit 93f10c7

Please sign in to comment.