Skip to content

Commit

Permalink
Error handling for differences in API structures
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMockler committed Dec 12, 2024
1 parent 497d57b commit fca1d86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/src/endpoint/drStory/synthesiseAndStoreSent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function synthesiseAndStoreSent (req:any) {
});

console.log(audioObj);
if (audioObj) {
if (audioObj && (audioObj.data.audioContent != "undefined")) {

const storedSent = await DigitalReaderSentenceAudio.create({
drStoryId: req.body.drStoryId,
Expand All @@ -61,6 +61,9 @@ async function synthesiseAndStoreSent (req:any) {
resolve('Response: ' + storedSent)
return;

} else {
resolve('undefined response from synthesis API')
return;
}
}
resolve('error storing the audio')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,13 @@ export class DigitalReaderStoryBuilderComponent implements OnInit {
}
console.log(audioObj)

// in case there was a problem during the batch synthesis
if (audioObj) {
if (audioObj.audioUrl == "data:audio/mp3;base64,undefined") {
audioObj = null;
}
}

// if the audio has not yet been created and, synthesise it and add it to the list.
if (!audioObj) {
audioObj = await this.synthRequest(this.currentSentence?.textContent, this.speaker);
Expand Down

0 comments on commit fca1d86

Please sign in to comment.