首页 > 解决方案 > iPhone 的 FLAC 录音未使用 Google Speech API 进行转换

问题描述

我已配置AVAudioRecorder如下以录制 Flac 格式的音频

记录仪配置

let settings: [String: Any] = [
            AVFormatIDKey: Int(kAudioFormatFLAC),
            AVSampleRateKey: 16000,
            AVNumberOfChannelsKey: 1,
            AVLinearPCMBitDepthKey: 16,
            AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue,
            AVLinearPCMIsBigEndianKey: false,
            AVLinearPCMIsFloatKey: false,
            ]

录音会议

recordingSession.setCategory(AVAudioSessionCategoryPlayAndRecord, with: [.allowBluetooth,.defaultToSpeaker])

文件记录成功并在设备中播放良好,也成功上传到后端服务。

问题某些音频文件无法使用Google Speech API

---->来自 Google Speech API 的问题

  1. 文件不包含 FLAC 标头
  2. soxi FAIL 格式:无法打开输入文件“636737069431546112.flac”:解码元数据时出现 FLAC 错误

标签: swiftavaudiorecordergoogle-speech-apiflaclaravel-5.7

解决方案


推荐阅读