Prechádzať zdrojové kódy

Improve AI Companion recording audibility by capturing mic audio at higher fidelity and boosting the microphone track during final meeting mixdown.

Made-with: Cursor
huzaifahayat12 2 mesiacov pred
rodič
commit
4e6322a820
1 zmenil súbory, kde vykonal 13 pridanie a 2 odobranie
  1. 13 2
      meetings_app/ViewController.swift

+ 13 - 2
meetings_app/ViewController.swift

@@ -1509,9 +1509,10 @@ private extension ViewController {
     private func startMicrophoneRecording(at outputURL: URL, showToast: Bool) {
         let settings: [String: Any] = [
             AVFormatIDKey: kAudioFormatMPEG4AAC,
-            AVSampleRateKey: 44_100,
+            AVSampleRateKey: 48_000,
             AVNumberOfChannelsKey: 1,
-            AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
+            AVEncoderBitRateKey: 128_000,
+            AVEncoderAudioQualityKey: AVAudioQuality.max.rawValue
         ]
         do {
             let recorder = try AVAudioRecorder(url: outputURL, settings: settings)
@@ -1646,8 +1647,18 @@ private extension ViewController {
         guard let export = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetAppleM4A) else {
             throw NSError(domain: "MeetingAudioMix", code: 2, userInfo: [NSLocalizedDescriptionKey: "Unable to create audio export session."])
         }
+
+        // Give the local microphone a small speech-focused boost while preserving meeting audio.
+        let systemMix = AVMutableAudioMixInputParameters(track: systemTrack)
+        systemMix.setVolume(1.0, at: .zero)
+        let micMix = AVMutableAudioMixInputParameters(track: micTrack)
+        micMix.setVolume(1.35, at: .zero)
+        let audioMix = AVMutableAudioMix()
+        audioMix.inputParameters = [systemMix, micMix]
+
         export.outputURL = destinationURL
         export.outputFileType = .m4a
+        export.audioMix = audioMix
         await withCheckedContinuation { continuation in
             export.exportAsynchronously {
                 continuation.resume()