Merge branch 'develop_liyi' into 'canary_release'

Develop liyi

See merge request StarlockTeam/app-starlock!13
This commit is contained in:
李仪 2025-04-02 09:07:35 +00:00
commit 823f498622
4 changed files with 89 additions and 27 deletions

View File

@ -1149,5 +1149,7 @@
"2.在APP里开启锁的远程开锁功能这个功能默认是关闭的。如果没有这个选项则锁不支持Google Home": "2. एप्लिकेशन में लॉक का रिमोट अनलॉकिंग फ़ंक्शन सक्षम करें (यह फ़ंक्शन डिफ़ॉल्ट रूप से बंद है). यदि यह विकल्प उपलब्ध नहीं है, तो लॉक आपके गूगल होम को सपोर्ट नहीं करेगा।", "2.在APP里开启锁的远程开锁功能这个功能默认是关闭的。如果没有这个选项则锁不支持Google Home": "2. एप्लिकेशन में लॉक का रिमोट अनलॉकिंग फ़ंक्शन सक्षम करें (यह फ़ंक्शन डिफ़ॉल्ट रूप से बंद है). यदि यह विकल्प उपलब्ध नहीं है, तो लॉक आपके गूगल होम को सपोर्ट नहीं करेगा।",
"3.安装Google Home APP点击左上角的加号按钮": "3. गूगल होम ऐप को इंस्टॉल करें और ऊपरी बाएं कोने में प्लस बटन पर क्लिक करें।", "3.安装Google Home APP点击左上角的加号按钮": "3. गूगल होम ऐप को इंस्टॉल करें और ऊपरी बाएं कोने में प्लस बटन पर क्लिक करें।",
"暂无最新记录": "वर्तमान में कोई नवीनतम रिकॉर्ड उपलब्ध नहीं हैं", "暂无最新记录": "वर्तमान में कोई नवीनतम रिकॉर्ड उपलब्ध नहीं हैं",
"繁体中文(中国台湾)": "पारंपरिक चीनी (ताइवान, चीनी)",
"繁体中文(中国香港)": "पारंपरिक चीनी (हांग कांग, चीनी)",
"请将手机切换至2.4G WiFi进行手动连接": "मैन्युअल कनेक्शन के लिए कृपया अपना फोन 2.4 जी वाईफ़ाई पर स्विच करें।" "请将手机切换至2.4G WiFi进行手动连接": "मैन्युअल कनेक्शन के लिए कृपया अपना फोन 2.4 जी वाईफ़ाई पर स्विच करें।"
} }

View File

@ -1045,15 +1045,15 @@
"一键开锁": "ایک کلک ان لاک", "一键开锁": "ایک کلک ان لاک",
"已开通": "کھولی", "已开通": "کھولی",
"英文": "انگريزی", "英文": "انگريزی",
"简体中文": "简体中文", "简体中文": "ساده چینی",
"繁体中文": "繁體中文", "繁体中文": "سنتی چینی",
"法语": "Francis", "法语": "فرانسوی",
"俄语": "Русский", "俄语": "روسی",
"德语": "Deutsch", "德语": "جرمن",
"日语": "日本語", "日语": "جاپانی",
"韩语": "한국어", "韩语": "کوریا",
"意大利语": "Italiano", "意大利语": "ایتالیایی",
"乌克兰语": "Українська", "乌克兰语": "Ukrainian",
"葡萄牙语": "Português", "葡萄牙语": "Português",
"西班牙语": "Español", "西班牙语": "Español",
"阿拉伯语": "العربية", "阿拉伯语": "العربية",
@ -1149,5 +1149,7 @@
"2.在APP里开启锁的远程开锁功能这个功能默认是关闭的。如果没有这个选项则锁不支持Google Home": "2. اے پی پی میں لاک کے ریموٹ ان لاکنگ فنکشن کو فعال کریں (یہ فنکشن ڈیفالٹ طور پر بند ہے)۔ اگر یہ آپشن دستیاب نہیں ہے تو ، لاک گوگل ہوم کو سپورٹ نہیں کرے گا۔", "2.在APP里开启锁的远程开锁功能这个功能默认是关闭的。如果没有这个选项则锁不支持Google Home": "2. اے پی پی میں لاک کے ریموٹ ان لاکنگ فنکشن کو فعال کریں (یہ فنکشن ڈیفالٹ طور پر بند ہے)۔ اگر یہ آپشن دستیاب نہیں ہے تو ، لاک گوگل ہوم کو سپورٹ نہیں کرے گا۔",
"3.安装Google Home APP点击左上角的加号按钮": "3. گوگل ہوم ایپ انسٹال کریں اور اوپری بائیں کونے میں پلس بٹن پر کلک کریں۔", "3.安装Google Home APP点击左上角的加号按钮": "3. گوگل ہوم ایپ انسٹال کریں اور اوپری بائیں کونے میں پلس بٹن پر کلک کریں۔",
"暂无最新记录": "فی الحال کوئی تازہ ترین ریکارڈ دستیاب نہیں ہے", "暂无最新记录": "فی الحال کوئی تازہ ترین ریکارڈ دستیاب نہیں ہے",
"繁体中文(中国台湾)": "(تائیوان، چین)سنتی چینی",
"繁体中文(中国香港)": "(ہنگ کنگ، چین)سنتی چینی",
"请将手机切换至2.4G WiFi进行手动连接": "براہ کرم دستی کنکشن کے لئے اپنے فون کو 2.4 جی وائی فائی پر سوئچ کریں" "请将手机切换至2.4G WiFi进行手动连接": "براہ کرم دستی کنکشن کے لئے اپنے فون کو 2.4 جی وائی فائی پر سوئچ کریں"
} }

View File

@ -381,7 +381,8 @@ class LockMainLogic extends BaseGetXController {
_initSubscription(); _initSubscription();
getUserInfoRequest(); getUserInfoRequest();
// connectListener(); // connectListener();
//
listenToLanguageChanges();
// AppLog.log('onInit() updateZoneOffsetsAndLanguages'); // AppLog.log('onInit() updateZoneOffsetsAndLanguages');
// updateZoneOffsetsAndLanguages(); // updateZoneOffsetsAndLanguages();
} }
@ -394,6 +395,16 @@ class LockMainLogic extends BaseGetXController {
super.onClose(); super.onClose();
} }
//
void listenToLanguageChanges() {
//
eventBus
.on<ChangeLanguageBlockLastLanguageEvent>()
.listen((ChangeLanguageBlockLastLanguageEvent event) {
getStarLockInfo(isUnShowLoading: true);
});
}
static LockMainLogic? to() { static LockMainLogic? to() {
if (Get.isRegistered<LockMainLogic>()) { if (Get.isRegistered<LockMainLogic>()) {
return Get.find<LockMainLogic>(); return Get.find<LockMainLogic>();

View File

@ -658,8 +658,22 @@ class TalkViewLogic extends BaseGetXController {
// //
Future<void> _onFrame(List<int> frame) async { Future<void> _onFrame(List<int> frame) async {
//
int maxVal = 0;
int minVal = 0;
int sum = 0;
for (int val in frame) {
maxVal = max(maxVal, val);
minVal = min(minVal, val);
sum += val;
}
double average = sum / frame.length;
AppLog.log('音频数据特征 - 最大值: $maxVal, 最小值: $minVal, 平均值: $average');
final List<int> processedFrame = preprocessAudio(frame); final List<int> processedFrame = preprocessAudio(frame);
final List<int> list = listLinearToALaw(processedFrame); //
final List<int> smoothedFrame = smoothAudio(processedFrame);
final List<int> list = listLinearToALaw(smoothedFrame);
_bufferedAudioFrames.addAll(list); _bufferedAudioFrames.addAll(list);
final int ms = DateTime.now().millisecondsSinceEpoch - final int ms = DateTime.now().millisecondsSinceEpoch -
@ -671,6 +685,15 @@ class TalkViewLogic extends BaseGetXController {
} }
if (_bufferedAudioFrames.length >= getFrameLength) { if (_bufferedAudioFrames.length >= getFrameLength) {
//
int maxVal = 0;
int minVal = 255;
for (int val in _bufferedAudioFrames) {
maxVal = max(maxVal, val);
minVal = min(minVal, val);
}
AppLog.log(
'发送音频数据 - G711编码后 - 最大值: $maxVal, 最小值: $minVal, 长度: ${_bufferedAudioFrames.length}');
// UDP // UDP
await StartChartManage() await StartChartManage()
.sendTalkDataMessage( .sendTalkDataMessage(
@ -691,19 +714,46 @@ class TalkViewLogic extends BaseGetXController {
AppLog.log(error.message!); AppLog.log(error.message!);
} }
//
List<int> preprocessAudio(List<int> pcmList) { List<int> preprocessAudio(List<int> pcmList) {
//
final List<int> processedList = []; final List<int> processedList = [];
final int noiseThreshold = 300; //
for (int pcmVal in pcmList) { for (int pcmVal in pcmList) {
// 0 //
if (pcmVal.abs() < 200) { if (pcmVal.abs() < noiseThreshold) {
pcmVal = 0; pcmVal = (pcmVal * 0.3).round(); //
} }
//
if (pcmVal.abs() > 20000) {
double factor = 1.0 - ((pcmVal.abs() - 20000) / 12768) * 0.3;
pcmVal = (pcmVal * factor).round();
}
processedList.add(pcmVal); processedList.add(pcmVal);
} }
return processedList; return processedList;
} }
//
List<int> smoothAudio(List<int> pcmList) {
final List<int> smoothedList = [];
for (int i = 0; i < pcmList.length; i++) {
if (i > 0 && i < pcmList.length - 1) {
//
int avg = (pcmList[i - 1] + pcmList[i] * 2 + pcmList[i + 1]) ~/ 4;
smoothedList.add(avg);
} else {
smoothedList.add(pcmList[i]);
}
}
return smoothedList;
}
//test测试降噪算法 //test测试降噪算法
// List<int> preprocessAudio(List<int> pcmList) { // List<int> preprocessAudio(List<int> pcmList) {
// final List<int> processedList = []; // final List<int> processedList = [];
@ -753,34 +803,31 @@ class TalkViewLogic extends BaseGetXController {
// return processedList; // return processedList;
// } // }
//
List<int> adjustVolume(List<int> pcmList, double volume) { List<int> adjustVolume(List<int> pcmList, double volume) {
final List<int> adjustedPcmList = <int>[]; final List<int> adjustedPcmList = <int>[];
for (final int pcmVal in pcmList) { for (final int pcmVal in pcmList) {
//
int adjustedPcmVal = (pcmVal * volume).round(); int adjustedPcmVal = (pcmVal * volume).round();
adjustedPcmVal = adjustedPcmVal.clamp(-32768, 32767);
// 16-bit PCM
if (adjustedPcmVal > 32767) {
adjustedPcmVal = 32767;
} else if (adjustedPcmVal < -32768) {
adjustedPcmVal = -32768;
}
adjustedPcmList.add(adjustedPcmVal); adjustedPcmList.add(adjustedPcmVal);
} }
return adjustedPcmList; return adjustedPcmList;
} }
// A-law编码
List<int> listLinearToALaw(List<int> pcmList) { List<int> listLinearToALaw(List<int> pcmList) {
// // 使
final List<int> adjustedPcmList = adjustVolume(pcmList, 5.0); final List<int> adjustedPcmList = adjustVolume(pcmList, 2.2);
// A-law // A-law编
final List<int> aLawList = <int>[]; final List<int> aLawList = <int>[];
for (final int pcmVal in adjustedPcmList) { for (final int pcmVal in adjustedPcmList) {
final int aLawVal = linearToALaw(pcmVal); final int aLawVal = linearToALaw(pcmVal);
aLawList.add(aLawVal); aLawList.add(aLawVal);
} }
return aLawList; return aLawList;
} }