UNPKG

@gravityai-dev/aws-toolkit

Version:

AWS services toolkit for Gravity workflow system - includes Transcribe and Textract

81 lines 3.19 kB
"use strict"; /** * Transcribe Node Executor * Handles audio-to-text conversion using AWS Transcribe */ Object.defineProperty(exports, "__esModule", { value: true }); exports.TranscribeExecutor = void 0; const transcribeAudio_1 = require("../service/transcribeAudio"); const platform_1 = require("../../shared/platform"); const index_1 = require("./index"); class TranscribeExecutor extends platform_1.PromiseNode { constructor() { super(index_1.NODE_TYPE); } async executeNode(inputs, config, context) { const logger = (0, platform_1.createLogger)("Transcribe"); // Get audio input - check both inputs and config const audioBase64 = config.audio; if (!audioBase64) { throw new Error("No audio input provided"); } // Validate base64 format if (typeof audioBase64 !== "string") { throw new Error("Audio input must be a base64 encoded string"); } logger.info("Starting audio transcription", { audioLength: audioBase64.length, languageCode: config.languageCode, autoDetectLanguage: config.autoDetectLanguage, enableSpeakerIdentification: config.enableSpeakerIdentification, }); try { // Build credential context for service const credentialContext = this.buildCredentialContext(context); // Call the transcribe service const result = await (0, transcribeAudio_1.transcribeAudio)({ audioBase64, mediaEncoding: config.mediaEncoding, languageCode: config.languageCode, autoDetectLanguage: config.autoDetectLanguage, languageOptions: config.languageOptions, enableSpeakerIdentification: config.enableSpeakerIdentification, maxSpeakers: config.maxSpeakers, vocabularyName: config.vocabularyName, filterProfanity: config.filterProfanity, logger: logger }, credentialContext.credentials?.aws, logger); logger.info("Transcription completed successfully", { textLength: result.text.length, languageCode: result.languageCode, confidence: result.confidence, hasSpeakerSegments: !!result.speakerSegments?.length, }); return result; } catch (error) { logger.error("Transcription failed", { error: error.message, code: error.code, stack: error.stack, }); throw error; } } /** * Build credential context from execution context */ buildCredentialContext(context) { return { credentials: { aws: context.credentials?.awsCredential || {}, }, nodeType: index_1.NODE_TYPE, workflowId: context.workflow?.id || "", executionId: context.executionId || "", nodeId: context.nodeId || "", }; } } exports.TranscribeExecutor = TranscribeExecutor; //# sourceMappingURL=executor.js.map