问题
Afternoon All -
So I think the title does say most of it but here goes. I'm new to the land of AWS and Lambda and having all sorts of fun learning this. I'm working on a project were I want to automagically merge two files stores in S3. I found this lambda function from the find folks at AWS (https://github.com/aws-samples/chime-voiceconnector-agent-assist/blob/master/infrastructure/function/src/retrieveMergedAudioUrl/lambda_function.py) and it references:
from pydub import AudioSegment
So what I haven't been able to quite figure out is, how do you import/build pydub in the world of lambda/serverless code.
Thanks,
Richard
回答1:
One option is you bundle pydub alongwith your code. We had similar situation and we had to bundle all dependencies. Ugly but it works.
回答2:
I feel you. I'm in the same position. "I just want to concatenate some audio files" is limited by the fact that ffmpeg
and ffprobe
combined is around 150MB. Add boto3 for python and you're not left with much else to squeeze in today's 250MB Lambda+layer combined images. So while you might get away with it at some point, once you hit that hard limit, you're in trouble.
I suspect the best solution is to create a separate pydub Lambda Function with parameters for source and destination S3 addresses + paths. Once someone's done this and it's open sourced, you can then deploy it in your own account and call it from your application-specific function.
If I manage to do this I'll share a link to it.
回答3:
I would recommend uploading pydub as a Lambda layer following these instructions (but subbing pydub in the requirements.txt). If you are running pydub locally, you can look up which version you're using with:
import pydub
print(pydub.__version__)
Full instructions are here: https://medium.com/@qtangs/creating-new-aws-lambda-layer-for-python-pandas-library-348b126e9f3e
来源:https://stackoverflow.com/questions/61667628/using-pydub-and-aws-lambda