feat: 添加降噪处理
This commit is contained in:
parent
911396e1f3
commit
5d5f913260
@ -570,8 +570,9 @@ class TalkViewLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onFrame(List<int> frame) async {
|
Future<void> _onFrame(List<int> frame) async {
|
||||||
final list = listLinearToALaw(frame);
|
final List<int> processedFrame = preprocessAudio(frame);
|
||||||
final ms = DateTime.now().millisecondsSinceEpoch -
|
final List<int> list = listLinearToALaw(processedFrame);
|
||||||
|
final int ms = DateTime.now().millisecondsSinceEpoch -
|
||||||
state.startRecordingAudioTime.value.millisecondsSinceEpoch;
|
state.startRecordingAudioTime.value.millisecondsSinceEpoch;
|
||||||
// 发送音频数据
|
// 发送音频数据
|
||||||
await StartChartManage().sendTalkDataMessage(
|
await StartChartManage().sendTalkDataMessage(
|
||||||
@ -588,6 +589,19 @@ class TalkViewLogic extends BaseGetXController {
|
|||||||
AppLog.log(error.message!);
|
AppLog.log(error.message!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<int> preprocessAudio(List<int> pcmList) {
|
||||||
|
// 简单的降噪处理
|
||||||
|
final List<int> processedList = [];
|
||||||
|
for (int pcmVal in pcmList) {
|
||||||
|
// 简单的降噪示例:将小于阈值的信号置为0
|
||||||
|
if (pcmVal.abs() < 500) {
|
||||||
|
pcmVal = 0;
|
||||||
|
}
|
||||||
|
processedList.add(pcmVal);
|
||||||
|
}
|
||||||
|
return processedList;
|
||||||
|
}
|
||||||
|
|
||||||
List<int> listLinearToALaw(List<int> pcmList) {
|
List<int> listLinearToALaw(List<int> pcmList) {
|
||||||
final List<int> aLawList = [];
|
final List<int> aLawList = [];
|
||||||
for (int pcmVal in pcmList) {
|
for (int pcmVal in pcmList) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user