-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created synthesis generation/storing pipeline on creation
Mongodb does not support cascade deletion so some work needs to be done to delete the audio files as well when a story is deleted
- Loading branch information
1 parent
f459f7e
commit 4019c2e
Showing
17 changed files
with
481 additions
and
407 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { API500Error } from "../../utils/APIError"; | ||
|
||
const DigitalReaderSentenceAudio = require('../../models/drSentenceAudio'); | ||
//const User = require('../../models/user'); | ||
const mongoose = require('mongoose'); | ||
const {API404Error} = require('../../utils/APIError'); | ||
|
||
const handler = async (req, res) => { | ||
|
||
function yes() { | ||
res.status(200).json({id: audio._id}); | ||
} | ||
function no(status=404, msg='not found') { | ||
res.status(status).json(msg); | ||
} | ||
|
||
console.log(req.body); | ||
|
||
//if (!req.body.audioPromise) return no(501, 'no audio promise provided'); | ||
if (!req.body.audioUrl) return no(501, 'no audio url provided'); | ||
if (!req.body.audioTiming) return no(501, 'no audio timing provided'); | ||
if (!req.body.drStoryId) return no(501, 'no story id provided'); | ||
if (req.body.sentId === undefined) return no(501, 'no sentence id provided'); | ||
if (!req.body.voice) return no(501, 'no voice code parameter provided'); | ||
|
||
// check that the current user owns the provided story (or is an admin) (?) | ||
|
||
let audio; | ||
|
||
//const audioPromise:Promise<any> = req.body.audioPromise; | ||
//console.log(audioPromise); | ||
|
||
//audioPromise.then( | ||
//async (response:any) => { | ||
//console.log(response); | ||
//const audioUrl = response.audioContent; | ||
//const timing = response.timing; | ||
//console.log(audioUrl); | ||
//if (audioUrl) { | ||
audio = await DigitalReaderSentenceAudio.create({ | ||
drStoryId: req.body.storyId, | ||
sentenceId: req.body.sentId, | ||
voice: req.body.voice, | ||
audioUrl: req.body.audioUrl, | ||
timing: req.body.audioTiming, | ||
}); | ||
if (!audio) { | ||
throw new API500Error('Unable to save audio file to DB. It may be too large'); | ||
} | ||
yes(); | ||
//} | ||
//} | ||
//); | ||
|
||
return no(); | ||
|
||
}; | ||
|
||
export = handler; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const mongoose = require('mongoose'); | ||
const Schema = mongoose.Schema; | ||
|
||
const DigitalReaderSentenceAudio = new Schema( | ||
{ | ||
drStoryId: { | ||
type: mongoose.Types.ObjectId, | ||
index: true, | ||
}, | ||
sentenceId: { | ||
type: Number, | ||
}, | ||
voice: { | ||
type: String, | ||
}, | ||
timing: { | ||
type: Array, | ||
}, | ||
audioUrl: { | ||
type: String, | ||
}, | ||
}, | ||
{ | ||
collection: 'drSentenceAudio', | ||
timestamps: true | ||
}, | ||
); | ||
|
||
export = mongoose.model('DigitalReaderSentenceAudio', DigitalReaderSentenceAudio); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.