alexa-voice-service-client icon indicating copy to clipboard operation
alexa-voice-service-client copied to clipboard

TypeError: 'NoneType' object is not iterable

Open Nitinvermaa opened this issue 3 years ago • 0 comments

Hi Team, I have used amazon polly to generate the wav file and passed it to the alexa client, but it's giving me the error as

for i, directive in enumerate(client.send_audio_file(f)): TypeError: 'NoneType' object is not iterable

Amazon polly code: import boto3 import os

os.environ['AWS_PROFILE'] = "NitinVermaAskCli" os.environ['AWS_DEFAULT_REGION'] = "us-east-1" polly_client = boto3.Session(aws_access_key_id='AKIAZYOFB32NZRDUP', aws_secret_access_key='jTuAUFmtQte4LfG0QIVuHS+E0kh1qJ3XVBmw', region_name='us-west-1').client('polly')

response = polly_client.synthesize_speech(VoiceId='Joanna', OutputFormat='mp3', Text = 'Alexa, ask doctor connect')

file = open('C:/Users/nitin.verma/PycharmProjects/AwsPolly/resources/alexa_doctor_connect.wav', 'wb') file.write(response['AudioStream'].read()) file.close()

Alexa_Client from alexa_client import AlexaClient

client = AlexaClient( client_id='amzn1.application-oa2-client.ce399dfcf5cf8b66c5d0c4cd1b03', secret='53a7c2f016764402f6c4bcf53ce7e8a0f4b9a37dfa46bf2fb31e3ccf099', refresh_token='Atzr|IwEBIEiWGBIY5fgZPrjzbdLgJfGdLGYHHInC6gDOTgTTGuCMM2H9aQWQ-7MZFn9NUmZXn-B_IHrRhG1WAi4geiE6PbohWIY81cMtK0tFAkYzkhGMDQNNXDoVMsVk1rTNr354ZopD3IQ5r1WSko8XzHLir-RskaaUERKyqEsOIEvqYlozmP6VjELnAJvglQYawtJFSf24QvmoUsFqUXdZ87eIudvWWMh-i37D25fWLQo230LzLf5D9IABshQs7nra3PFF2cacKU1Q3IL3op7738tPzxf4q32GGECsvi5lXQHk0NlYU7JgjIa-adoKSIToE9ZHV2kf2-XB5jdqlpelMBeoB6d8wH9XjXB4ZpP-RNNx9EEAaP9p7YJ04EMY', ) client.connect() # authenticate and other handshaking steps with open('C:/Users/nitin.verma/PycharmProjects/AwsPolly/resources/alexa_doctor_connect.wav', 'rb') as f: for i, directive in enumerate(client.send_audio_file(f)): if directive.name in ['Speak', 'Play']: with open(f'./output_{i}.mp3', 'wb') as f: f.write(directive.audio_attachment) print('done')

Requesting you to please help me out to resolve this.

Nitinvermaa avatar Mar 19 '21 18:03 Nitinvermaa