File tree Expand file tree Collapse file tree 2 files changed +2
-6
lines changed
firebaseai/LiveAudioExample Expand file tree Collapse file tree 2 files changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ extension AVAudioPCMBuffer {
4242 /// Gets the underlying `Data` in this buffer.
4343 ///
4444 /// Will throw an error if this buffer doesn't hold int16 data.
45- func int16Data( ) -> Data ? {
45+ func int16Data( ) -> Data {
4646 guard let bufferPtr = audioBufferList. pointee. mBuffers. mData else {
4747 fatalError ( " Missing audio buffer list " )
4848 }
Original file line number Diff line number Diff line change @@ -130,11 +130,7 @@ class LiveViewModel: ObservableObject {
130130 let stream = try audioController. listenToMic ( )
131131 microphoneTask = Task {
132132 for await audioBuffer in stream {
133- guard let data = audioBuffer. int16Data ( ) else {
134- logger. error ( " Failed to convert audio buffer to int16 Data. " )
135- continue
136- }
137- await liveSession. sendAudioRealtime ( data)
133+ await liveSession. sendAudioRealtime ( audioBuffer. int16Data ( ) )
138134 }
139135 }
140136 }
You can’t perform that action at this time.
0 commit comments