Reputation: 1
Using an AWS Lambda function to use some of Microsoft Azure TTS API. Having trouble and getting error just trying to import "import azure.cognitiveservices.speech as speechsdk". Uploaded needed dependency correctly with pip3 install azure-cognitiveservices-speech -t .
Seems to be a problem with AWS runtime being linux, works fine locally on mac machine. Could anyone help? Might have to do with uploading a custom docker image like this solution or some sort of problem with this, but not sure how to add this dependency to aws lambda.
Thanks a bunch.
Upvotes: 0
Views: 608
Reputation: 1864
To resolve this Unable to import module 'lambda_function': No module named '_speech_py_impl'
error, try following way:
You might have installed azure-cognitiveservices-speech
in the wrong directory.
According to documentation:
1. Open AWS EC2 environment:
$ sudo amazon-linux-extras install python3.8
$ curl -O https://bootstrap.pypa.io/get-pip.py
$ python3.8 get-pip.py --user
2. Create Python folder:
$ mkdir python
3. Install azure.cognitiveservices.speech
:
$ python3.8 -m pip install azure.cognitiveservices.speech -t python/
4. Zip the contents:
$ zip -r layer.zip python
5. Publish the Lambda layer with the AWS region where your Lambda function is located:
aws lambda publish-layer-version --layer-name azure.cognitiveservices.speech-layer --zip-file fileb://layer.zip --compatible-runtimes python3.8 --region <your AWS region>
References: Unable to import module 'lambda_function', AWS Lambda Python error - Runtime.ImportModuleError and ModuleNotFoundError: No module named '_speech_py_impl'
Upvotes: 1