You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sbgowtham edited this page Nov 10, 2023
·
1 revision
from boto3 import Session
from botocore.exceptions import BotoCoreError, ClientError
from contextlib import closing
import os
import sys
import subprocess
from tempfile import gettempdir
if “AudioStream” in response:
with closing(response[“AudioStream”]) as stream:
output = os.path.join(gettempdir(), “/home/ubuntu/speech.mp3”)
try:
with open(output, “wb”) as file:
file.write(stream.read())
except IOError as error:
print(error)
sys.exit(-1)
else:
print(“Could not stream audio”)
sys.exit(-1)