Como converter CMSampleBuffer para dados no Swift?
Eu preciso converterCMSampleBuffer
paraData
formato. Estou usando uma estrutura de terceiros para tarefas relacionadas a áudio. Essa estrutura fornece o fluxo de áudio (ou seja, áudio em tempo real)CMSampleBuffer
objeto.
Como isso:
func didAudioStreaming(audioSample: CMSampleBuffer!) {
//Here I need to conver this to Data format.
//Because I am using GRPC framework for Audio Recognization,
}
Forneça-me as etapas para converter oCMSampleBuffer
paraData
.
Para sua informação
let formatDesc:CMFormatDescription? = CMSampleBufferGetFormatDescription(audioSample)
<CMAudioFormatDescription 0x17010d890 [0x1b453ebb8]> {
mediaType:'soun'
mediaSubType:'lpcm'
mediaSpecific: {
ASBD: {
mSampleRate: 16000.000000
mFormatID: 'lpcm'
mFormatFlags: 0xc
mBytesPerPacket: 2
mFramesPerPacket: 1
mBytesPerFrame: 2
mChannelsPerFrame: 1
mBitsPerChannel: 16 }
cookie: {(null)}
ACL: {(null)}
FormatList Array: {(null)}
}
extensions: {(null)}
}