repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
project-lakechain
github_2023
awslabs
typescript
LanceDbLayer.arm64
static arm64(scope: Construct, id: string): lambda.LayerVersion { const architecture = lambda.Architecture.ARM_64; // The Docker image to use to build the layer. const image = cdk.DockerImage.fromRegistry( 'public.ecr.aws/sam/build-nodejs18.x:1.124.0-arm64' ); // Builds the LanceDB library f...
/** * @param scope the construct scope. * @param id the construct identifier. * @returns a lambda layer version for the LanceDB library * compiled for ARM64. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/lancedb/index.ts#L34-L73
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
LanceDbLayer.x64
static x64(scope: Construct, id: string): lambda.LayerVersion { const architecture = lambda.Architecture.X86_64; // The Docker image to use to build the layer. const image = cdk.DockerImage.fromRegistry( 'public.ecr.aws/sam/build-nodejs18.x:1.124.0-x86_64' ); // Builds the LanceDB library fo...
/** * @param scope the construct scope. * @param id the construct identifier. * @returns a lambda layer version for the LanceDB library * compiled for X64. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/lancedb/index.ts#L81-L120
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MediaInfoLayer.fromArch
static fromArch( scope: Construct, id: string, architecture: lambda.Architecture, version: string = DEFAULT_MEDIA_INFO_VERSION ): lambda.LayerVersion { const archName = architecture === lambda.Architecture.ARM_64 ? 'arm64' : 'x64'; // The Docker image to use to build the layer. const imag...
/** * @param scope the construct scope. * @param id the construct identifier. * @param architecture the architecture to build the layer for. * @returns a lambda layer version for the MediaInfo library * compiled for the given architecture. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/mediainfo/index.ts#L40-L91
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MediaInfoLayer.x64
static x64(scope: Construct, id: string, version: string = DEFAULT_MEDIA_INFO_VERSION): lambda.LayerVersion { return (MediaInfoLayer.fromArch(scope, id, lambda.Architecture.X86_64, version)); }
/** * @param scope the construct scope. * @param id the construct identifier. * @returns a lambda layer version for the MediaInfo library * compiled for x64. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/mediainfo/index.ts#L99-L101
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
MediaInfoLayer.arm64
static arm64(scope: Construct, id: string, version: string = DEFAULT_MEDIA_INFO_VERSION): lambda.LayerVersion { return (MediaInfoLayer.fromArch(scope, id, lambda.Architecture.ARM_64, version)); }
/** * @param scope the construct scope. * @param id the construct identifier. * @returns a lambda layer version for the MediaInfo library * compiled for ARM64. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/mediainfo/index.ts#L109-L111
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PowerToolsPythonLayer.x64
static x64(scope: Construct, id: string, version = 60): lambda.ILayerVersion { return (lambda.LayerVersion.fromLayerVersionArn(scope, id, `arn:aws:lambda:${cdk.Aws.REGION}:017000801446:layer:AWSLambdaPowertoolsPythonV2:${version}` )); }
/** * @param scope the construct scope. * @param id the construct identifier. * @param version the layer version to use. * @returns a lambda layer version for the AWS PowerTools Python library * compiled for x64. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/powertools/index.ts#L33-L37
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PowerToolsPythonLayer.arm64
static arm64(scope: Construct, id: string, version = 60): lambda.ILayerVersion { return (lambda.LayerVersion.fromLayerVersionArn(scope, id, `arn:aws:lambda:${cdk.Aws.REGION}:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:${version}` )); }
/** * @param scope the construct scope. * @param id the construct identifier. * @param version the layer version to use. * @returns a lambda layer version for the AWS PowerTools Python library * compiled for ARM64. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/powertools/index.ts#L46-L50
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PowerToolsTypescriptLayer.layer
static layer(scope: Construct, id: string, version = 27): lambda.ILayerVersion { return (lambda.LayerVersion.fromLayerVersionArn(scope, id, `arn:aws:lambda:${cdk.Aws.REGION}:094274105915:layer:AWSLambdaPowertoolsTypeScript:${version}` )); }
/** * @param scope the construct scope. * @param id the construct identifier. * @returns a lambda layer version for the AWS PowerTools Typescript library. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/powertools/index.ts#L63-L67
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PowerToolsLayer.python
static python() { return (PowerToolsPythonLayer); }
/** * @returns a lambda layer version for the AWS Python PowerTools * library, compatible with both x64 and ARM64 architectures. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/powertools/index.ts#L80-L82
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PowerToolsLayer.typescript
static typescript() { return (PowerToolsTypescriptLayer); }
/** * @returns a lambda layer version for the AWS Typescript PowerTools * library. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/powertools/index.ts#L88-L90
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
SharpLayer.arm64
static arm64(scope: Construct, id: string): lambda.LayerVersion { const architecture = lambda.Architecture.ARM_64; // The Docker image to use to build the layer. const image = cdk.DockerImage.fromRegistry( 'public.ecr.aws/sam/build-nodejs18.x:1.124.0-arm64' ); // Builds the Sharp library for...
/** * @param scope the construct scope. * @param id the construct identifier. * @returns a lambda layer version for the Sharp library * compiled for ARM64. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/layers/src/sharp/index.ts#L34-L73
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
AudioMetadataExtractorBuilder.build
public build(): AudioMetadataExtractor { return (new AudioMetadataExtractor( this.scope, this.identifier, { ...this.props } )); }
/** * @returns a new instance of the `AudioMetadataExtractor` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/audio-metadata-extractor/src/index.ts#L72-L79
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
AudioMetadataExtractor.constructor
constructor(scope: Construct, id: string, private props: MiddlewareProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 3 * PROCESSING_TIMEOUT.toSeconds() ) }); /////////////////////////////////////////// /////// Processing Functi...
/** * Provider constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/audio-metadata-extractor/src/index.ts#L101-L158
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
AudioMetadataExtractor.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { // Since this middleware simply passes through the data // from the previous middleware, we grant any subsequent // middlewares in the pipeline read access to the // data of all source middlewares. for (const source of this.sources) {...
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/audio-metadata-extractor/src/index.ts#L164-L173
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
AudioMetadataExtractor.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'audio/mpeg', 'audio/mp4', 'audio/wav', 'audio/x-wav', 'audio/x-m4a', 'audio/ogg', 'audio/x-flac', 'audio/flac', 'audio/x-aiff', 'audio/aiff', 'audio/x-ms-wma', 'audio/x-matroska', 'audio/webm',...
/** * @returns an array of mime-types supported as input * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/audio-metadata-extractor/src/index.ts#L179-L196
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
AudioMetadataExtractor.supportedOutputTypes
supportedOutputTypes(): string[] { return (this.supportedInputTypes()); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/audio-metadata-extractor/src/index.ts#L202-L204
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
AudioMetadataExtractor.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/audio-metadata-extractor/src/index.ts#L210-L214
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
AudioMetadataExtractor.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/audio-metadata-extractor/src/index.ts#L223-L228
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
getImage
const getImage = (picture: any) => { return ({ type: picture.format, data: picture.data.toString('base64') }); };
/** * @param picture a picture object provided by the * `music-metadata` library. * @returns an image description object. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/audio-metadata-extractor/src/lambdas/metadata-extractor/get-metadata.ts#L31-L36
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
toFixed
const toFixed = (num: number, digits = 0, base = 10) => { const pow = Math.pow(base, digits); return (Math.round(num * pow) / pow); };
/** * A small helper allowing * @param num the number to convert into a decimal * fixed digits number. * @param digits the number of decimal digits to keep. * @param base the base associated with the number. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/audio-metadata-extractor/src/lambdas/metadata-extractor/get-metadata.ts#L45-L48
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
async handler(event: SQSEvent, _: Context): Promise<SQSBatchResponse> { return (await processPartialResponse( event, (record: SQSRecord) => this.processEvent( CloudEvent.from(JSON.parse(record.body)) ), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/audio-metadata-extractor/src/lambdas/metadata-extractor/index.ts#L79-L87
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizerBuilder.constructor
constructor() { super(); this.providerProps.voiceMapping = {}; }
/** * Builder constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L58-L61
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizerBuilder.withLanguageOverride
public withLanguageOverride(language: BarkLanguage) { this.providerProps.languageOverride = language; return (this); }
/** * Specifies the language to assume the source * document being written in. * @param language the language to assume. * @returns the builder itself. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L69-L72
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizerBuilder.withVoiceMapping
public withVoiceMapping(language: BarkLanguage, ...voiceArray: BarkVoice[]) { const languageVoices = this.providerProps.voiceMapping![language]; // Verify that the voices match the given language. const incompatibleVoices = voiceArray.filter(voice => !voices .filter(voice => voice.LanguageCod...
/** * Specifies a mapping between a language and a voice descriptor. * @param language the language to map. * @param voice the voice descriptor to map. * @see https://suno-ai.notion.site/8b8e8749ed514b0cbf3f699013548683?v=bc67cff786b04b50b3ceb756fd05f68c * @returns the builder itself. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L81-L108
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizerBuilder.withTemperature
public withTemperature(temperature: number) { this.providerProps.temperature = temperature; return (this); }
/** * Specifies the temperature to pass to the Bark generative model * when generating text to speech. * @param temperature the temperature to use. * @returns the builder itself. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L116-L119
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizerBuilder.withMaxInstances
public withMaxInstances(maxInstances: number) { this.providerProps.maxInstances = maxInstances; return (this); }
/** * The maximum amount of instances the * cluster can have. Keep this number to * a reasonable value to avoid over-provisioning * the cluster. * @param maxInstances the maximum amount of instances. * @default 5 */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L129-L132
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizerBuilder.build
public build(): BarkSynthesizer { return (new BarkSynthesizer( this.scope, this.identifier, { ...this.providerProps as BarkSynthesizerProps, ...this.props } )); }
/** * @returns a new instance of the `BarkSynthesizer` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L138-L146
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizer.constructor
constructor(scope: Construct, id: string, private props: BarkSynthesizerProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.minutes(30) }); // Validate the properties. this.props = this.parse(BarkSynthesizerPropsSchema, props); //////////////////////...
/** * Provider constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L168-L267
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizer.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L273-L275
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizer.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'text/plain' ]); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L281-L285
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizer.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'audio/mpeg' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L291-L295
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizer.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.GPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L301-L305
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
BarkSynthesizer.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/bark-synthesizer/src/index.ts#L314-L319
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizerBuilder.withApiKey
public withApiKey(apiKey: secrets.ISecret) { this.middlewareProps.apiKey = apiKey; return (this); }
/** * Sets the API key to use. * @param apiKey the API key to use. * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L96-L99
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizerBuilder.withModel
public withModel(model: ElevenLabsModel) { this.middlewareProps.model = model; return (this); }
/** * The model to use for the synthesis. * @param model the model to use. * @default 'eleven_multilingual_v2' * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L107-L110
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizerBuilder.withVoice
public withVoice(voice: string, settings?: VoiceSettings) { if (settings) { this.middlewareProps.voiceSettings = settings; } this.middlewareProps.voice = voice; return (this); }
/** * The voice to use for the synthesis. * @param voice the voice to use. * @param settings the voice settings to use. * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L118-L124
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizerBuilder.withOutputFormat
public withOutputFormat(format: ElevenLabs.OutputFormat) { this.middlewareProps.outputFormat = format; return (this); }
/** * The output format to use for the synthesis. * @param format the format to use. * @default mp3_44100_128 * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L132-L135
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizerBuilder.build
public build(): ElevenLabsSynthesizer { return (new ElevenLabsSynthesizer( this.scope, this.identifier, { ...this.middlewareProps as ElevenLabsSynthesizerProps, ...this.props } )); }
/** * @returns a new instance of the `ElevenLabsSynthesizer` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L141-L149
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizer.constructor
constructor(scope: Construct, id: string, private props: ElevenLabsSynthesizerProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 2 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validate the properties. this.props = this.parse(ElevenLab...
/** * Construct constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L176-L262
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizer.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L268-L270
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizer.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'text/plain' ]); }
/** * @returns an array of mime-types supported as input * type by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L276-L280
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizer.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'audio/mpeg' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L286-L290
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizer.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L296-L300
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
ElevenLabsSynthesizer.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/index.ts#L309-L314
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettingsBuilder.withStability
public withStability(stability: number) { this.props.stability = stability; return (this); }
/** * Sets the stability slider. * @see https://elevenlabs.io/docs/speech-synthesis/voice-settings * @param stability the stability slider. * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L82-L85
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettingsBuilder.withSimilarityBoost
public withSimilarityBoost(similarity: number) { this.props.similarity_boost = similarity; return (this); }
/** * Sets the similarity slider. * @see https://elevenlabs.io/docs/speech-synthesis/voice-settings * @param similarity the similarity slider. * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L93-L96
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettingsBuilder.withStyle
public withStyle(style: number) { this.props.style = style; return (this); }
/** * Sets the style slider. * @see https://elevenlabs.io/docs/speech-synthesis/voice-settings * @param style the style slider. * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L104-L107
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettingsBuilder.withSpeakerBoost
public withSpeakerBoost(useSpeakerBoost: boolean) { this.props.use_speaker_boost = useSpeakerBoost; return (this); }
/** * Sets whether to enable speaker boost. * @see https://elevenlabs.io/docs/speech-synthesis/voice-settings * @param useSpeakerBoost whether to enable speaker boost. * @returns the builder instance. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L115-L118
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettingsBuilder.build
public build(): VoiceSettings { return (VoiceSettings.from(this.props)); }
/** * @returns a new instance of the `VoiceSettings` * constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L124-L126
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettings.constructor
constructor(public props: VoiceSettingsProps) {}
/** * Creates a new instance of the `VoiceSettings` class. * @param props the task properties. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L143-L143
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettings.getStability
public getStability() { return (this.props.stability); }
/** * @returns the stability slider. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L148-L150
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettings.getSimilarityBoost
public getSimilarityBoost() { return (this.props.similarity_boost); }
/** * @returns the similarity slider. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L155-L157
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettings.getStyle
public getStyle() { return (this.props.style); }
/** * @returns the style slider. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L162-L164
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettings.getSpeakerBoost
public getSpeakerBoost() { return (this.props.use_speaker_boost); }
/** * @returns whether to enable speaker boost. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L169-L171
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettings.from
public static from(props: any) { return (new VoiceSettings(VoiceSettingsPropsSchema.parse(props))); }
/** * Creates a new instance of the `VoiceSettings` class. * @param props the task properties. * @returns a new instance of the `VoiceSettings` class. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L178-L180
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
VoiceSettings.toJSON
public toJSON() { return (this.props); }
/** * @returns the JSON representation of the task. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/definitions/voice-settings.ts#L185-L187
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
streamToBuffer
const streamToBuffer = async (readable: NodeJS.ReadableStream): Promise<Buffer> => { const chunks: Buffer[] = []; for await (const chunk of readable) { chunks.push(chunk as Buffer); } return (Buffer.concat(chunks)); }
/** * Convert a readable stream to a buffer. * @param readable the readable stream to convert. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/lambdas/processor/index.ts#L95-L101
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getOutputType
private getOutputType(): { mimeType: string, extension: string } { if (ELEVENLABS_OUTPUT_FORMAT.startsWith('mp3')) { return ({ mimeType: 'audio/mpeg', extension: 'mp3' }); } else if (ELEVENLABS_OUTPUT_FORMAT.startsWith('pcm')) { return ({ mimeType: 'audio/L16', extension: 'pcm' }); } else if (EL...
/** * @returns the output type based on the output format. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/lambdas/processor/index.ts
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
async handler(event: SQSEvent, _: Context): Promise<SQSBatchResponse> { return (await processPartialResponse( event, (record: SQSRecord) => this.processEvent( CloudEvent.from(JSON.parse(record.body)) ), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/elevenlabs-synthesizer/src/lambdas/processor/index.ts#L163-L171
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizerBuilder.constructor
constructor() { super(); this.providerProps.voiceMapping = {}; }
/** * Builder constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L79-L82
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizerBuilder.withLanguageOverride
public withLanguageOverride(language: PollyLanguage) { this.providerProps.languageOverride = language; return (this); }
/** * Specifies the language to assume the source * document being written in. * @see https://docs.aws.amazon.com/polly/latest/dg/SupportedLanguage.html * @param language the language to assume. * @returns the builder itself. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L91-L94
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizerBuilder.withVoiceMapping
public withVoiceMapping(language: PollyLanguage, ...voiceArray: VoiceDescriptor[]) { const languageVoices = this.providerProps.voiceMapping![language]; // Verify that the voices match the given language. const incompatibleVoices = voiceArray.filter(voice => !map .filter(voice => voice['ISO-63...
/** * Specifies a mapping between a language and a voice descriptor. * @param language the language to map. * @param voice the voice descriptor to map. * @see https://docs.aws.amazon.com/polly/latest/dg/voicelist.html * @returns the builder itself. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L103-L130
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizerBuilder.build
public build(): PollySynthesizer { return (new PollySynthesizer( this.scope, this.identifier, { ...this.providerProps as PollySynthesizerProps, ...this.props } )); }
/** * @returns a new instance of the `PollySynthesizer` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L136-L144
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizer.constructor
constructor(scope: Construct, id: string, private props: PollySynthesizerProps) { super(scope, id, description, { ...props, queueVisibilityTimeout: cdk.Duration.seconds( 6 * PROCESSING_TIMEOUT.toSeconds() ) }); // Validating the properties. this.props = this.parse(PollySynthes...
/** * Provider constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L188-L297
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizer.createEventHandler
private createEventHandler(id: string): lambda.IFunction { return (new node.NodejsFunction(this, id, { description: 'A function creating synthesis tasks on Amazon Polly.', entry: path.resolve(__dirname, 'lambdas', 'event-handler', 'index.js'), vpc: this.props.vpc, timeout: PROCESSING_TIMEOUT...
/** * Creates the event handler lambda function. * @param id the identifier of the lambda function. * @returns the lambda function. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L304-L335
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizer.createResultHandler
private createResultHandler(id: string): lambda.IFunction { return (new node.NodejsFunction(this, id, { description: 'A function handling results from Amazon Polly.', entry: path.resolve(__dirname, 'lambdas', 'result-handler', 'index.js'), vpc: this.props.vpc, timeout: PROCESSING_TIMEOUT, ...
/** * Creates the result handler lambda function. * @param id the identifier of the lambda function. * @returns the lambda function. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L342-L371
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizer.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L377-L379
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizer.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'text/plain' ]); }
/** * @returns an array of mime-types supported as input * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L385-L389
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizer.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'audio/mpeg' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L395-L399
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizer.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L405-L409
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
PollySynthesizer.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/index.ts#L418-L423
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
groupBy
const groupBy = <T, K extends keyof any>(arr: T[], key: (i: T) => K) => arr.reduce((groups, item) => { (groups[key(item)] ||= []).push(item); return groups; }, {} as Record<K, T[]> );
/** * Group an array of elements by a given key. * @param arr the array to group. * @param key the key to group by. * @returns a record mapping the given key to the * elements of the array. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/lambdas/event-handler/get-descriptor.ts#L46-L51
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
getTtl
const getTtl = () => { const SECONDS_IN_AN_HOUR = 60 * 60; return (Math.round(Date.now() / 1000) + (24 * SECONDS_IN_AN_HOUR)); };
/** * This method computes the time-to-live value for events stored in DynamoDB. * The purpose is to ensure that elements within the table are automatically * deleted after a certain amount of time. * @returns a time-to-live value for events stored in DynamoDB. * @default 24 hours. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/lambdas/event-handler/index.ts#L72-L75
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.processEvent
async processEvent(event: CloudEvent): Promise<any> { const document = event.data().document(); const ttl = getTtl(); // Load the input document in memory. const text = await document.data().asBuffer(); // Resolve the language, voice and engine to use. const descriptor = getDescriptor(eve...
/** * @param event the event to process. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/lambdas/event-handler/index.ts#L88-L123
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
async handler(event: SQSEvent, _: Context): Promise<SQSBatchResponse> { return (await processPartialResponse( event, (record: SQSRecord) => this.processEvent( CloudEvent.from(JSON.parse(record.body)) ), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/lambdas/event-handler/index.ts#L132-L140
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getJobEvent
private async getJobEvent(taskId: string): Promise<CloudEvent> { const { Item } = await dynamodb.send(new GetItemCommand({ TableName: process.env.MAPPING_TABLE, Key: { SynthesisTaskId: { S: taskId } } })); return (CloudEvent.from(JSON.parse(Item?.event.S as string))); }
/** * @param taskId the Amazon Polly task identifier * associated with the cloud event to retrieve. * @returns the cloud event associated with the given * Amazon Polly task identifier. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/lambdas/result-handler/index.ts#L61-L69
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getObject
private async getObject(bucket: string, key: string): Promise<HeadObjectCommandOutput> { const res = await s3.send(new HeadObjectCommand({ Bucket: bucket, Key: key })); return (res); }
/** * Retrieves object metadata from S3. * @param bucket the bucket name. * @param key the object key. * @returns the object metadata. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/lambdas/result-handler/index.ts#L77-L83
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
async handler(event: SNSEvent, _: Context): Promise<any> { for (const record of event.Records) { try { await this.processEvent(JSON.parse(record.Sns.Message)); } catch (err) { logger.error(err as any); throw err; } } }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/polly-synthesizer/src/lambdas/result-handler/index.ts#L115-L124
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessorBuilder.withOutputFormats
public withOutputFormats(...formats: OutputFormat[]) { this.providerProps.outputFormats = formats; return (this); }
/** * Sets the output format to use. * @param formats the output formats to use as * an output of the transcription. * @default ['vtt'] */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L73-L76
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessorBuilder.build
public build(): TranscribeAudioProcessor { return (new TranscribeAudioProcessor( this.scope, this.identifier, { ...this.providerProps as TranscribeAudioProcessorProps, ...this.props } )); }
/** * @returns a new instance of the `TranscribeAudioProcessor` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L82-L90
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessor.constructor
constructor(scope: Construct, id: string, private props: TranscribeAudioProcessorProps) { super(scope, id, description, props); // Validate the properties. this.props = this.parse(TranscribeAudioProcessorSchema, props); /////////////////////////////////////////// ///////// Processing Storage ...
/** * Provider constructor. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L124-L238
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessor.onSourceAdded
protected onSourceAdded(source: Middleware): void { super.onSourceAdded(source); source.grantReadProcessedDocuments(this.transcribeRole); }
/** * Called back when a new source middleware is connected * to this middleware. The purpose of overriding this method * is to allow the Amazon Transcribe role to access the source's * processed documents. * @param source the source middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L247-L250
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessor.createInputHandler
private createInputHandler(id: string) { const handlerPath = path.resolve(__dirname, 'lambdas', 'input-handler'); // Compiling the properties into options that the Amazon Transcribe // API understands. const transcribeOptions = compile( this.props, this.storage.id(), this.transcribeRo...
/** * Creates a new input handler function which handles * events from the middleware's input queue and writes * them to the DynamoDB table for further processing. * @param id the construct identifier. * @returns the input handler function. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L259-L297
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessor.createResultHandler
private createResultHandler(id: string) { const handlerPath = path.resolve(__dirname, 'lambdas', 'result-handler'); return (new node.NodejsFunction(this, id, { description: 'Listens for transcription results and forwards them to the SNS topic.', entry: path.resolve(handlerPath, 'index.js'), v...
/** * @param id the construct identifier. * @returns the result handler function which handles * transcription results and forwards them to the SNS topic. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L304-L333
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessor.grantReadProcessedDocuments
grantReadProcessedDocuments(grantee: iam.IGrantable): iam.Grant { return (this.storage.grantRead(grantee)); }
/** * Allows a grantee to read from the processed documents * generated by this middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L339-L341
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessor.supportedInputTypes
supportedInputTypes(): string[] { return ([ 'audio/mpeg', 'audio/mp4', 'audio/x-m4a', 'audio/wav', 'audio/webm', 'audio/flac', 'audio/x-flac', 'audio/ogg', 'audio/x-ogg', 'audio/amr' ]); }
/** * @returns an array of mime-types supported as input * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L347-L360
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessor.supportedOutputTypes
supportedOutputTypes(): string[] { return ([ 'application/json', 'application/x-subrip', 'text/vtt' ]); }
/** * @returns an array of mime-types supported as output * type by the data producer. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L366-L372
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessor.supportedComputeTypes
supportedComputeTypes(): ComputeType[] { return ([ ComputeType.CPU ]); }
/** * @returns the supported compute types by a given * middleware. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L378-L382
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
TranscribeAudioProcessor.conditional
conditional() { return (super .conditional() .and(when('type').equals('document-created')) ); }
/** * @returns the middleware conditional statement defining * in which conditions this middleware should be executed. * In this case, we want the middleware to only be invoked * when the document mime-type is supported, and the event * type is `document-created`. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/index.ts#L391-L396
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
getTtl
const getTtl = () => { const SECONDS_IN_AN_HOUR = 60 * 60; return (Math.round(Date.now() / 1000) + (24 * SECONDS_IN_AN_HOUR)); };
/** * This method computes the time-to-live value for events stored in DynamoDB. * The purpose is to ensure that elements within the table are automatically * deleted after a certain amount of time. * @returns a time-to-live value for events stored in DynamoDB. * @default 24 hours. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/lambdas/input-handler/index.ts#L64-L67
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.processEvent
async processEvent(event: CloudEvent): Promise<any> { const document = event.data().document(); const chainId = event.data().chainId(); const jobId = `${chainId}-${document.etag()}`; const ttl = getTtl(); // Create the transcription job. await transcribe.send(new StartTranscriptionJobC...
/** * This method processes the received event and stores * it in DynamoDB for further processing. * @param event the event to process. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/lambdas/input-handler/index.ts#L82-L116
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
async handler(event: SQSEvent, _: Context): Promise<SQSBatchResponse> { return (await processPartialResponse( event, (record: SQSRecord) => this.processEvent( CloudEvent.from(JSON.parse(record.body)) ), processor )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/lambdas/input-handler/index.ts#L126-L134
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
unquote
const unquote = (key: string): string => { return (decodeURIComponent(key.replace(/\+/g, " "))); };
/** * When S3 emits an event, it will encode the object key * in the event record using quote-encoding. * This function restores the object key in its unencoded * form and returns the event record with the unquoted object key. * @param event the S3 event record. * @returns the S3 event record with the unquoted ob...
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/lambdas/result-handler/index.ts#L53-L55
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.getJobEvent
private async getJobEvent(jobId: string): Promise<CloudEvent> { const { Item } = await dynamodb.send(new GetItemCommand({ TableName: process.env.MAPPING_TABLE, Key: { TranscriptionJobId: { S: jobId } } })); return (CloudEvent.from(JSON.parse(Item?.event.S as string))); }
/** * @param jobId the Amazon Transcribe job identifier * associated with the cloud event to retrieve. * @returns the cloud event associated with the given * Amazon Transcribe job identifier. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/lambdas/result-handler/index.ts#L71-L79
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
Lambda.handler
handler(event: S3Event, _: Context): Promise<any> { return (Promise.all( event.Records.map((record) => this.recordHandler(record)) )); }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/transcribe-audio-processor/src/lambdas/result-handler/index.ts#L124-L128
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
WhisperTranscriberBuilder.withEngine
public withEngine(engine: WhisperEngine) { this.whisperProps.engine = engine; return (this); }
/** * Sets the Whisper engine to use. * @param engine the Whisper engine to use. * @default openai_whisper */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/whisper-transcriber/src/index.ts#L60-L63
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
WhisperTranscriberBuilder.withModel
public withModel(model: WhisperModel) { this.whisperProps.model = model; return (this); }
/** * Sets the Whisper model to use. * @param model the Whisper model to use. * @default small */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/whisper-transcriber/src/index.ts#L70-L73
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
WhisperTranscriberBuilder.withOutputFormat
public withOutputFormat(format: OutputFormat) { this.whisperProps.outputFormat = format; return (this); }
/** * Sets the output format to use. * @param format the output format to use. * @default vtt */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/whisper-transcriber/src/index.ts#L80-L83
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
WhisperTranscriberBuilder.withMaxInstances
public withMaxInstances(maxInstances: number) { this.whisperProps.maxInstances = maxInstances; return (this); }
/** * The maximum amount of instances the * cluster can have. Keep this number to * a reasonable value to avoid over-provisioning * the cluster. * @param maxInstances the maximum amount of instances. * @default 5 */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/whisper-transcriber/src/index.ts#L93-L96
4285173e80584eedfc1a8424d3d1b6c1a7038088
project-lakechain
github_2023
awslabs
typescript
WhisperTranscriberBuilder.build
public build(): WhisperTranscriber { return (new WhisperTranscriber( this.scope, this.identifier, { ...this.whisperProps as WhisperTranscriberProps, ...this.props } )); }
/** * @returns a new instance of the `WhisperTranscriber` * service constructed with the given parameters. */
https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/audio-processors/whisper-transcriber/src/index.ts#L102-L110
4285173e80584eedfc1a8424d3d1b6c1a7038088