I want to use lambda function to parse the response returned by Sagemaker endpoint. My function should get a text as an input and parse it, then return. In function body there will be invoked get_result(), which uses .vocab file as an argument. I have uploaded .vocab file and get_result.py to my lambda function directory. I don't know what to do with dependencies that get_result() uses. Here is how the lambda function looks like
import os
import io
import boto3
import json
import csv
ENDPOINT_NAME = os.environ['ENDPOINT_NAME']
runtime= boto3.client('runtime.sagemaker')
def lambda_handler(event, context):
sagemaker_runtime = boto3.client('sagemaker-runtime', region_name='us-east-1')
print("Received event: " + json.dumps(event, indent=2))
data = json.loads(json.dumps(event))
payload = data['data']
print(payload)
with open("tmp_splitted/voice_6539544344_Hamaspyur_3093_34.wav", "rb") as file:
audio_data = file.read()
response = sagemaker_runtime.invoke_endpoint(
EndpointName=endpoint_name,
ContentType="audio/x-audio", # Change this to the appropriate audio format
Accept="application/json",
Body=audio_data
)
print(response)
result = json.loads(response['Body'].read().decode())
print(result)
best_correction = get_best_correction(result)
return best_correction
When I press test button I see this result, can someone help me to understand why do I see the result of last test?