如何将AWS Kinesis Video Stream GetMedia API输出解码为mp3/wav? [英] How to decode AWS Kinesis Video Stream GetMedia API output to mp3/wav?

本文介绍了如何将AWS Kinesis Video Stream GetMedia API输出解码为mp3/wav?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在使用GetMedia API通过AWS Connect服务将数据摄取到(Kinesis Video Stream)KVS,能够提取有效负载,但是如何将输出转换为mp3/wav?我想将此输出提取到AWS Transcribe服务,以获取AWS Connect服务提取到KVS的音频呼叫的文本格式.

I ingested data to (Kinesis Video Stream) KVS via AWS Connect service now using GetMedia API am able to extract the Payload but how can I convert this output to a mp3/wav ? I want to ingest this output to AWS Transcribe service to get text format of audio call ingested by AWS Connect service to KVS.

以下代码的有效负载的输出类似于:

Output of Payload for below code is like :

00#AWS_KINESISVIDEO_CONTINUATION_TOKEND \ x87 .... \ x1faudio/L16; rate = 8000; channels = 1; \ x12T \ xc ...... 00"AWS_KINESISVIDEO_MILLIS_BEHIND_NOWD \ x87 \ x10 \ x00 \ x00 \ x074564302g \ xc8 \ x10 \ x00 \ x00 ^ E \ xa3 \ x10 \ x00 \ x00#AWS_KINESISVIDEO_CONTINUATION_TOKEND \ x87 \ x10 \ x00 \ x00/91343852333181432506572546233025969376791063'

00#AWS_KINESISVIDEO_CONTINUATION_TOKEND\x87....\x1faudio/L16;rate=8000;channels=1;\x12T\xc......00"AWS_KINESISVIDEO_MILLIS_BEHIND_NOWD\x87\x10\x00\x00\x074564302g\xc8\x10\x00\x00^E\xa3\x10\x00\x00#AWS_KINESISVIDEO_CONTINUATION_TOKEND\x87\x10\x00\x00/91343852333181432506572546233025969374566791063'

注意:上面的响应太长,因此请粘贴其中一些.

Note: Above response was too long, so pasted some of it.

import json
import boto3

kinesis_client = boto3.client('kinesisvideo', region_name='us-east-1')

response = kinesis_client.get_data_endpoint(
    StreamARN='arn:aws:kinesisvideo:us-east-1:47...,
    APIName='GET_MEDIA')

t = response['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:47...',
    StartSelector={'StartSelectorType': 'EARLIEST'})

streamingBody = stream['Payload']
print(streamingBody.read())

请建议如何将有效负载输出转换为mp3/wav等.

推荐答案

我遇到了同样的问题,我可以将有效负载作为原始文件导出到S3,但是当我收听它时,它听不见,就像一个原始文件一样.加密的对话.

I am facing the same problem, I can export the payload to S3 as a raw file but when I listen it, it is not properly audible like it was a crypted conversation.

我只是将有效负载保存到文件中.

I just save the payload into a file.

f = open("myAudio.wav", 'w+b')
f.write(stream['Payload'].read())
f.close() 

这篇关于如何将AWS Kinesis Video Stream GetMedia API输出解码为mp3/wav?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆