From 7d58420b77e4603bac81b07cdf056985fe3f5d6d Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Wed, 4 Sep 2024 09:27:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eai=E9=99=8D=E5=99=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 2 ++ src/components/StupWizard/index.tsx | 40 +++++++++++++++++++++++++++-- src/utils/package/agora.ts | 10 ++++++-- src/utils/styles/App.scss | 7 ++++- vite.config.ts | 6 +++-- 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 6221e4a..865745a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -119,6 +119,8 @@ const App: React.FC = () => { shareFilesPath: path.resolve(__dirname, '../../Downloads/') + '\\', //共享文件保存路径 isShareSavePath: true, //是否下载钱询问每个文件保存的位置 closeSetting: 'hide', //关闭按钮设置 + isAINoiseReduction: true, //是否开启ai降噪 + aINoiseReduction: 0, // 降噪模式 })) } }, []) diff --git a/src/components/StupWizard/index.tsx b/src/components/StupWizard/index.tsx index 45de259..d7ba541 100644 --- a/src/components/StupWizard/index.tsx +++ b/src/components/StupWizard/index.tsx @@ -1,6 +1,6 @@ import styles from '@/components/StupWizard/index.module.scss' import ImageUrl from '@/utils/package/imageUrl'; -import { Button, Checkbox, Empty, Input, message, Modal, Popover, Radio, Select, Slider } from 'antd'; +import { Button, Checkbox, Empty, Input, message, Modal, Popover, Radio, Select, Slider, Space } from 'antd'; import { forwardRef, useEffect, useImperativeHandle, useState } from "react"; import { agora } from '@/utils/package/agora' import { CloseOutlined, LoadingOutlined, QuestionCircleOutlined } from '@ant-design/icons'; @@ -243,6 +243,8 @@ const AudioComponents = () => { ecordingActive: false, ecordingVolume: 0, autoEcordingVolume: true, + isAINoiseReduction: true, + aINoiseReduction: 0 }); const setting = JSON.parse(storage.getItem('setting') as string) useEffect(() => { @@ -288,7 +290,9 @@ const AudioComponents = () => { ecordingItem: setting.ecordingDeviceId, ecordingVolume: setting.ecordingVolume, playBackVolume: setting.playBackVolume, - autoEcordingVolume: setting.autoEcordingVolume + autoEcordingVolume: setting.autoEcordingVolume, + isAINoiseReduction: setting.isAINoiseReduction, + aINoiseReduction: setting.aINoiseReduction, }) } return ( @@ -350,6 +354,38 @@ const AudioComponents = () => { }) }} disabled={!audioDeviceManager.ecordingItem} /> +
+
+ { + setting.isAINoiseReduction = e.target.checked; + storage.setItem('setting', JSON.stringify(setting)) + setAudioDeviceManager({ + ...audioDeviceManager, + isAINoiseReduction: e.target.checked + }) + agora.setAINSMode(e.target.checked, audioDeviceManager.aINoiseReduction) + }}> + AI降噪 + +
+
+ { + setting.aINoiseReduction = e.target.value; + storage.setItem('setting', JSON.stringify(setting)) + setAudioDeviceManager({ + ...audioDeviceManager, + aINoiseReduction: e.target.value + }) + agora.setAINSMode(audioDeviceManager.isAINoiseReduction, e.target.value) + }} disabled={!audioDeviceManager.isAINoiseReduction} value={audioDeviceManager.aINoiseReduction}> + + 均衡降噪模式 + 强降噪模式 + 低延时强降噪模式 + + +
+
{/*
{ setting.autoEcordingVolume = e.target.checked; diff --git a/src/utils/package/agora.ts b/src/utils/package/agora.ts index d087da7..be6d7b3 100644 --- a/src/utils/package/agora.ts +++ b/src/utils/package/agora.ts @@ -5,7 +5,8 @@ import { VideoViewSetupMode, ScreenCaptureSourceType, RenderModeType, - ChannelProfileType + ChannelProfileType, + AudioAinsMode } from "agora-electron-sdk"; import { GetRoomRtcToken } from "@/api/Home/Index"; import { storage } from '@/utils'; @@ -92,6 +93,7 @@ export const agora = { if (setting.playBackVolume) agora.setPlaybackDeviceVolume(setting.playBackVolume) // 设置播放设备音量 if (setting.ecordingDeviceId) agora.setRecordingDevice(setting.ecordingDeviceId) // 设置音频采集设备 if (setting.ecordingVolume) agora.setRecordingDeviceVolume(setting.ecordingVolume) // 设置音频设备音量 + if (setting.isAINoiseReduction) agora.setAINSMode(setting.isAINoiseReduction, setting.aINoiseReduction) // 设置ai降噪 } }, 1000); }, @@ -242,7 +244,7 @@ export const agora = { option.tokenA, { channelId: option.channelId + 'a', localUid: Number('1' + option.screenShareId) }, { - clientRoleType: bool ? ClientRoleType.ClientRoleAudience : ClientRoleType.ClientRoleBroadcaster , //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众 + clientRoleType: bool ? ClientRoleType.ClientRoleAudience : ClientRoleType.ClientRoleBroadcaster, //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众 autoSubscribeAudio: false,//设置是否自动订阅所有音频流 autoSubscribeVideo: true,//设置是否自动订阅所有视频流 publishMicrophoneTrack: false,//设置是否发布麦克风采集到的音频 @@ -256,6 +258,10 @@ export const agora = { await agora.stopCameraCapture(); await rtcEngine.leaveChannelEx({ channelId: option.channelId + 'a', localUid: Number('1' + option.screenShareId) }) }, + // ai降噪 + setAINSMode: async (enabled: boolean, mode: AudioAinsMode) => { + rtcEngine.setAINSMode(enabled, mode) + }, // 离开共享屏幕频道 leaveChannelEx: async (uid: any) => { await rtcEngine.leaveChannelEx({ channelId: option.channelId, localUid: Number(uid) }) diff --git a/src/utils/styles/App.scss b/src/utils/styles/App.scss index 16140e3..9aafaca 100644 --- a/src/utils/styles/App.scss +++ b/src/utils/styles/App.scss @@ -343,11 +343,16 @@ $pagination-hover-background-color: #5575F2; } .ant-radio-checked .ant-radio-inner { - border-color: $btn-background-color; background-color: $btn-background-color; + border-color: $btn-background-color; } } +:where(.css-dev-only-do-not-override-98ntnt).ant-radio-wrapper .ant-radio-disabled .ant-radio-inner { + background-color: #28282C; + border-color: #28282C; +} + // ant-notification .ant-notification { .ant-notification-notice-wrapper { diff --git a/vite.config.ts b/vite.config.ts index e34ce19..2a9a83b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -60,7 +60,8 @@ export default defineConfig({ RenderModeType, ScreenCaptureSourceType, VideoSourceType, - VideoViewSetupMode + VideoViewSetupMode, + AudioAinsMode } = require("agora-electron-sdk") export { createAgoraRtcEngine, @@ -69,7 +70,8 @@ export default defineConfig({ RenderModeType, ScreenCaptureSourceType, VideoSourceType, - VideoViewSetupMode + VideoViewSetupMode, + AudioAinsMode } `, })