AWS Lambda Event Handler
audio_splitter.lambda_function
lambda_handler(event, context)
Event listener for S3 event and calls the split audio function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
AWS Event
|
A JSON-formatted document that contains data for a Lambda function to process. |
required |
context |
AWS Event
|
An object that provides methods and properties that provide information about the invocation, function, and runtime environment. |
required |
Raises:
Type | Description |
---|---|
e
|
Audio cannot be obtained from S3. |
Source code in src/audio_splitter/lambda_function.py
split_export_audio(annotations, annotation_key, audio_file, bucket, key_prefix)
Splits audio_file
based on JSON-formatted annotations
, saves exports to
key_prefix
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
annotations |
List[Dict[str, Any]]
|
description |
required |
annotation_key |
str
|
JSON-formatted annotations exported by Label Studio. |
required |
audio_file |
str
|
Key of annotation dictionary containing timestamps and transcriptions. |
required |
bucket |
str
|
Pre-signed URL pointing to the audio file of the JSON annotation. |
required |
key_prefix |
str
|
AWS S3 key prefix path to save file. |
required |
Source code in src/audio_splitter/lambda_function.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
trim_audio(input_path, start, end)
Trims audio from input_path
from start
to end
(in seconds), pipes output
audio stdout and stderr.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_path |
str
|
Input file URL ( |
required |
start |
float
|
Timestamp (in seconds) of the start of the section to keep. |
required |
end |
float
|
Specify time of the first audio sample that will be dropped. |
required |
Returns:
Type | Description |
---|---|
Tuple[bytes, bytes]
|
Tuple[bytes, bytes]: Tuple-pair of stdout and stderr bytes. |