(voice, text)
| 49 | return response['TranslatedText'] |
| 50 | |
| 51 | def convert_text_to_speech(voice, text): |
| 52 | if voice not in ['Joanna', 'Matthew', 'Lupe']: |
| 53 | print('Only Joanna, Matthew and Lupe support the newscaster style') |
| 54 | sys.exit(1) |
| 55 | response = polly_c.synthesize_speech( |
| 56 | VoiceId=voice, |
| 57 | Engine='neural', |
| 58 | OutputFormat='mp3', |
| 59 | TextType='ssml', |
| 60 | Text = f'<speak><amazon:domain name="news">{text}></amazon:domain></speak>') |
| 61 | |
| 62 | return response['AudioStream'].read() |