Я только что клонировал официальный звук к тексту с помощью проекта DeepGram от GitHub:-https://github.com/deepgram-devs/deepgr ... ts-ios.git
Я добавил свой ключ API, запустил код в моем IOS 16 Pro Simulator, и я получаю эту ошибку. />Thread 1: "required condition is false: IsFormatSampleRateAndChannelCountValid(format)" AVAudioEngine
Вот код viewcontroler, который помогает записать Audio и Streampe to Deepgram:-
Void in
if let data = self.toNSData(buffer: buffer) {
self.socket.write(data: data)
}
}
audioEngine.connect(inputNode, to: converterNode, format: inputFormat)
audioEngine.connect(converterNode, to: sinkNode, format: outputFormat)
audioEngine.prepare()
do {
try AVAudioSession.sharedInstance().setCategory(.record)
try audioEngine.start()
} catch {
print(error)
}
}
private func toNSData(buffer: AVAudioPCMBuffer) -> Data? {
let audioBuffer = buffer.audioBufferList.pointee.mBuffers
return Data(bytes: audioBuffer.mData!, count: Int(audioBuffer.mDataByteSize))
}
}
extension ViewController: WebSocketDelegate {
func didReceive(event: WebSocketEvent, client: WebSocket) {
switch event {
case .text(let text):
let jsonData = Data(text.utf8)
let response = try! jsonDecoder.decode(DeepgramResponse.self, from: jsonData)
let transcript = response.channel.alternatives.first!.transcript
if response.isFinal && !transcript.isEmpty {
if transcriptView.text.isEmpty {
transcriptView.text = transcript
} else {
transcriptView.text = transcriptView.text + " " + transcript
}
}
case .error(let error):
print(error ?? "")
default:
break
}
}
}
struct DeepgramResponse: Codable {
let isFinal: Bool
let channel: Channel
struct Channel: Codable {
let alternatives: [Alternatives]
}
struct Alternatives: Codable {
let transcript: String
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... ountvalidf
Тема 1: «Требуемое условие неверно: isformatsamplerateandChannelCountValid (format)» AvaudioEngine ⇐ IOS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение