-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from AgoraIO/ios-voice-effects
Ios voice effects
- Loading branch information
Showing
10 changed files
with
347 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import SwiftUI | ||
import AgoraRtcKit | ||
|
||
class NoiseSuppressionManager: AgoraManager { | ||
@discardableResult | ||
func setNoiseSuppression(_ enable: Bool, mode: AUDIO_AINS_MODE) -> Int32 { | ||
self.agoraEngine.setAINSMode(enable, mode: mode) | ||
} | ||
} | ||
|
||
enum AinsModes: String { | ||
case none | ||
case aggressive | ||
case balanced | ||
case ultraLowLatency | ||
var agoraCase: AUDIO_AINS_MODE? { | ||
switch self { | ||
case .none: nil | ||
case .aggressive: AUDIO_AINS_MODE.AINS_MODE_AGGRESSIVE | ||
case .balanced: AUDIO_AINS_MODE.AINS_MODE_BALANCED | ||
case .ultraLowLatency: AUDIO_AINS_MODE.AINS_MODE_ULTRALOWLATENCY | ||
} | ||
} | ||
} | ||
|
||
/// A view that encrypts your channel connection through Agora. | ||
struct AINoiseSuppView: View { | ||
/// The Agora SDK manager. | ||
@ObservedObject var agoraManager = NoiseSuppressionManager( | ||
appId: DocsAppConfig.shared.appId, role: .broadcaster | ||
) | ||
@State var ainsMode: AinsModes = .none | ||
|
||
var body: some View { | ||
ZStack { | ||
VStack { | ||
self.basicScrollingVideos | ||
Picker("Choose Noise Suppression", selection: $ainsMode) { | ||
ForEach([ | ||
AinsModes.none, .balanced, .aggressive, .ultraLowLatency | ||
], id: \.rawValue) { Text($0.rawValue).tag($0) } | ||
}.pickerStyle(SegmentedPickerStyle()) | ||
}.onChange(of: ainsMode) { newValue in | ||
if let agoraCase = newValue.agoraCase { | ||
self.agoraManager.setNoiseSuppression(true, mode: agoraCase) | ||
} else { | ||
self.agoraManager.setNoiseSuppression(false, mode: .AINS_MODE_BALANCED) | ||
} | ||
} | ||
ToastView(message: $agoraManager.label) | ||
}.onAppear { | ||
await agoraManager.joinChannel(DocsAppConfig.shared.channel) | ||
}.onDisappear { agoraManager.leaveChannel() } | ||
} | ||
|
||
/// Initializes a new `MediaEncryptionView`. | ||
/// | ||
/// - Parameters: | ||
/// - channelId: The channel ID to join. | ||
public init(channelId: String) { | ||
DocsAppConfig.shared.channel = channelId | ||
} | ||
static let docPath = getFolderName(from: #file) | ||
static let docTitle = LocalizedStringKey("ai-noise-suppression-title") | ||
} | ||
|
||
#Preview { | ||
AINoiseSuppView(channelId: "test") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# AI noise suppression | ||
|
||
Agora's AI Noise Suppression, enables you to suppress hundreds of types of noise and reduce distortion in human voices when multiple people speak at the same time. In scenarios such as online meetings, online chat rooms, video consultations with doctors, and online gaming, AI Noise Suppression makes virtual communication as smooth as face-to-face interaction. | ||
|
||
AI Noise Suppression reduces the following types of noise: | ||
|
||
* Television | ||
* Kitchen | ||
* Street, such as birds chirping, traffic, and subway sounds | ||
* Machine, such as fans, air conditioners, vacuum cleaners, and copiers | ||
* Office, such as keyboard and mouse clicks | ||
* Household, such as doors opening, creaking chairs, crying babies, and house renovations | ||
* Constant knocking | ||
* Beeps and clapping | ||
* Music | ||
|
||
This sample project shows you how to enable AI noise suppression in your client. | ||
|
||
## Understand the code | ||
|
||
For context on this sample, and a full explanation of the essential code snippets used in this project, read the **AI Noise Suppression** document for your product of interest: | ||
|
||
* [Video calling](https://docs.agora.io/en/video-calling/enable-features/ai-noise-suppression?platform=ios) | ||
* [Interactive live Streaming](https://docs.agora.io/en/interactive-live-streaming/enable-features/ai-noise-suppression?platform=ios) | ||
* [Broadcast streaming](https://docs.agora.io/en/broadcast-streaming/enable-features/ai-noise-suppression?platform=ios) | ||
|
||
For the UI implementation of this example, refer to [`AINoiseSuppView.swift`](./AINoiseSuppView.swift). | ||
|
||
## How to run this example | ||
|
||
To see how to run this example, refer to the [README](../README.md) in the root folder or one of the complete product guides. |
Oops, something went wrong.