尝试将Amazon Connect配置为与AWS Kinesis Video Streams进行实时流对话,然后触发使用GetMedia API的Lambda函数(Python)对该记录进行采样并将其发送到某些S3存储桶。
这种原始流到.wav的转换非常困难->甚至可以用python实现吗? 找到了类似的实现,但总是偶然发现Java(https://github.com/aws-samples/amazon-connect-realtime-transcription)。
例如,我只需要将此流转换为.wav格式,以便以后可由普通音频播放器播放并用作语音邮件,并用于类似的用例中。
import json
import boto3
import time
bucket='kinesis-video-streams-random'
key = 'streams/latest.raw'
def lambda_handler(event, context):
try:
s3_client = boto3.client('s3',region_name='us-east-1')
kinesis_client = boto3.client('kinesisvideo',region_name='us-east-1')
get_ep = kinesis_client.get_data_endpoint(StreamARN='arn:aws:kinesisvideo:us-east-1:xxxxxxxxx:stream/xxxxxxxx',APIName='GET_MEDIA')
t = get_ep['DataEndpoint']
video_client = boto3.client('kinesis-video-media', endpoint_url=t, region_name='us-east-1')
stream = video_client.get_media(StreamARN='arn:aws:kinesisvideo:us-east-1:xxxxxxxxx:stream/xxxxxxxx',StartSelector={'StartSelectorType': 'EARLIEST'})
s3_client.put_object(Bucket=bucket, Key=key, Body=stream['Payload'].read())
print("Specific Kinesis Stream stored in the S3 bucket " + bucket)
except Exception as e:
return e