The first time I'm trying to use AWS. I need to integrate AWS Polish with an asterisk for text to speech.
here is an example of code i written to convert text to speech
from boto3 import client import boto3 import StringIO from contextlib import closing polly = client("polly", 'us-east-1' ) response = polly.synthesize_speech( Text="Good Morning. My Name is Rajesh. I am Testing Polly AWS Service For Voice Application.", OutputFormat="mp3", VoiceId="Raveena") print(response) if "AudioStream" in response: with closing(response["AudioStream"]) as stream: data = stream.read() fo = open("pollytest.mp3", "w+") fo.write( data ) fo.close()
I get the following error.
Traceback (most recent call last): File "pollytest.py", line 11, in <module> VoiceId="Raveena") File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 253, in _api_call return self._make_api_call(operation_name, kwargs) File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 530, in _make_api_call operation_model, request_dict) File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 141, in make_request return self._send_request(request_dict, operation_model) File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 166, in _send_request request = self.create_request(request_dict, operation_model) File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 150, in create_request operation_name=operation_model.name) File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line 227, in emit return self._emit(event_name, kwargs) File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line 210, in _emit response = handler(**kwargs) File "/usr/local/lib/python2.7/dist-packages/botocore/signers.py", line 90, in handler return self.sign(operation_name, request) File "/usr/local/lib/python2.7/dist-packages/botocore/signers.py", line 147, in sign auth.add_auth(request) File "/usr/local/lib/python2.7/dist-packages/botocore/auth.py", line 316, in add_auth raise NoCredentialsError botocore.exceptions.NoCredentialsError: Unable to locate credentials
I want to provide the credentials directly in this script so that I can use this in the asterisk system application.
UPDATE: created a ~ / .aws / credentials file with the contents below
[default] aws_access_key_id=XXXXXXXX aws_secret_access_key=YYYYYYYYYYY
now for my current login user, its work is fine, but for asterisk PBX it does not work.