From 7e9f0edb78f2ad35674e2863093fa29457d1431d Mon Sep 17 00:00:00 2001 From: TLuigi003 Date: Mon, 28 Oct 2019 21:27:15 +0100 Subject: [PATCH 1/2] - Fixed error accessing to event info --- functions/extractAudio.js | 5 +++-- functions/transcribeAudio.js | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/functions/extractAudio.js b/functions/extractAudio.js index 2e507e6..c87a741 100644 --- a/functions/extractAudio.js +++ b/functions/extractAudio.js @@ -1,11 +1,12 @@ const storageUtils = require('../utils/storage-utils'); const ffmpegUtils = require('../utils/ffmpeg-utils'); module.exports = (event) => { + console.log(`event.data ${JSON.stringify(event)}`); return Promise.resolve() .then(() => { - const videoFile = storageUtils.videoBucket.file(event.data.name); + const videoFile = storageUtils.videoBucket.file(event.name); console.log('downloading video file 2...'); - return storageUtils.downloadFile(videoFile, event.data.name); + return storageUtils.downloadFile(videoFile, event.name); }).then((fileinfo) => { //extract audio and transcode to FLAC return ffmpegUtils.extractAudio(fileinfo); diff --git a/functions/transcribeAudio.js b/functions/transcribeAudio.js index 3c0e38a..5cd3ff9 100644 --- a/functions/transcribeAudio.js +++ b/functions/transcribeAudio.js @@ -3,12 +3,12 @@ const path = require('path'); const storageUtils = require('../utils/storage-utils'); const speechUtils = require('../utils/speech-utils'); module.exports = (event) => { - console.log(`event.data ${JSON.stringify(event.data)}`); + console.log(`event.data ${JSON.stringify(event)}`); let audioFileNameWithoutExtension; return Promise.resolve() .then(() => { - console.log(`event.data.name: ${JSON.stringify(event.data.name)}`); - const audioFile = storageUtils.flacBucket.file(event.data.name); + console.log(`event.data.name: ${JSON.stringify(event.name)}`); + const audioFile = storageUtils.flacBucket.file(event.name); const audioFilePath = storageUtils.getFilePathFromFile(audioFile); console.log(`audioFilePath: ${JSON.stringify(audioFilePath)}`); audioFileNameWithoutExtension = path.parse(audioFilePath).name; From 5d95af35800a1fdb5bc7ecc7a69e4dd7670eec07 Mon Sep 17 00:00:00 2001 From: TLuigi003 Date: Tue, 29 Oct 2019 18:51:49 +0100 Subject: [PATCH 2/2] Added number of channels of audio that seems to fix some bad transcription cases --- functions/transcribeAudio.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/transcribeAudio.js b/functions/transcribeAudio.js index 5cd3ff9..8c2b32a 100644 --- a/functions/transcribeAudio.js +++ b/functions/transcribeAudio.js @@ -16,7 +16,8 @@ module.exports = (event) => { "config": { "enableWordTimeOffsets": true, "languageCode": "en-US", - "encoding": "FLAC" + "encoding": "FLAC", + "audioChannelCount": 1 }, "audio": { "uri": audioFilePath