-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_action_lambda.py
More file actions
63 lines (54 loc) · 1.93 KB
/
Copy pathtest_action_lambda.py
File metadata and controls
63 lines (54 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Test the action group Lambda directly.
"""
import json
import boto3
lambda_client = boto3.client('lambda', region_name='us-west-2')
# Test transcribe action
event = {
'actionGroup': 'video-processing-actions',
'apiPath': '/transcribe_video',
'httpMethod': 'POST',
'parameters': [
{'name': 'bucket_name', 'value': 'my-video-lambda-bucket'},
{'name': 'video_key', 'value': 'videos/videoplayback.mp4'}
]
}
print("Testing Action Group Lambda - Transcribe Video")
print("="*60)
print(f"Event: {json.dumps(event, indent=2)}")
print("="*60)
try:
response = lambda_client.invoke(
FunctionName='video-processing-action-group',
InvocationType='RequestResponse',
Payload=json.dumps(event)
)
payload = json.loads(response['Payload'].read())
print(f"\nLambda Status: {response['StatusCode']}")
print(f"\nResponse:")
print(json.dumps(payload, indent=2))
# Parse the action response
if 'response' in payload:
response_body = payload['response']['responseBody']['application/json']['body']
result = json.loads(response_body)
if result.get('success'):
print("\n" + "="*60)
print("✓ TRANSCRIPTION SUCCESSFUL")
print("="*60)
print(f"\nTranscript Preview (first 500 chars):")
print(result['transcript'][:500] + "...")
print(f"\nWord Count: {result['word_count']}")
print(f"Duration: {result['duration']} seconds")
print(f"Language: {result['language']}")
print(f"Confidence: {result['confidence']:.2%}")
else:
print("\n" + "="*60)
print("✗ TRANSCRIPTION FAILED")
print("="*60)
print(f"Error: {result.get('error')}")
print(f"Message: {result.get('message')}")
except Exception as e:
print(f"\n✗ Error: {str(e)}")
import traceback
traceback.print_exc()