Skip to content

Commit 01da380

Browse files
Merge pull request #25 from codeforequity-at/bugfix/BOT-3350-voip-user-input-in-bot-response
added audio file information endpoint
2 parents b5d7cbf + e3d5dda commit 01da380

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@aws-sdk/client-s3": "^3.53.1",
1818
"@aws-sdk/client-transcribe": "^3.53.0",
1919
"@aws-sdk/client-transcribe-streaming": "^3.53.0",
20+
"@aws-sdk/util-endpoints": "^3.53.0",
2021
"@google-cloud/speech": "^4.10.0",
2122
"@google-cloud/storage": "^5.18.2",
2223
"@google-cloud/text-to-speech": "^3.4.0",

frontend/src/routes.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,51 @@ router.post('/api/stt/:language', async (req, res, next) => {
481481
}
482482
}))
483483

484+
/**
485+
* @swagger
486+
* /api/audio/info:
487+
* post:
488+
* description: Returns information about audio file
489+
* security:
490+
* - ApiKeyAuth: []
491+
* requestBody:
492+
* description: Audio file
493+
* content:
494+
* audio/wav:
495+
* schema:
496+
* type: string
497+
* format: binary
498+
* responses:
499+
* 200:
500+
* description: Audio information
501+
* content:
502+
* application/json:
503+
* schema:
504+
* type: object
505+
*/
506+
router.post('/api/audio/info', async (req, res, next) => {
507+
let buffer = null
508+
if (Buffer.isBuffer(req.body)) {
509+
buffer = req.body
510+
} else {
511+
buffer = await extractMultipartContent(req, res)
512+
}
513+
514+
if (!buffer) {
515+
return next(new Error('req.body is not a buffer'))
516+
}
517+
518+
const duration = await getAudioLengthSeconds(buffer)
519+
520+
try {
521+
res.json({
522+
duration
523+
})
524+
} catch (err) {
525+
return next(err)
526+
}
527+
})
528+
484529
/**
485530
* @swagger
486531
* /api/convertprofiles:

frontend/src/swagger.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,39 @@
358358
}
359359
}
360360
},
361+
"/api/audio/info": {
362+
"post": {
363+
"description": "Returns information about audio file",
364+
"security": [
365+
{
366+
"ApiKeyAuth": []
367+
}
368+
],
369+
"requestBody": {
370+
"description": "Audio file",
371+
"content": {
372+
"audio/wav": {
373+
"schema": {
374+
"type": "string",
375+
"format": "binary"
376+
}
377+
}
378+
}
379+
},
380+
"responses": {
381+
"200": {
382+
"description": "Audio information",
383+
"content": {
384+
"application/json": {
385+
"schema": {
386+
"type": "object"
387+
}
388+
}
389+
}
390+
}
391+
}
392+
}
393+
},
361394
"/api/convertprofiles": {
362395
"get": {
363396
"description": "Get list of audio conversion profile",

0 commit comments

Comments
 (0)