From 0f149027d95c715fdc802df8ff591a82546cceba Mon Sep 17 00:00:00 2001
From: Armor <2654988228@qq.com>
Date: Sun, 28 Dec 2025 11:58:39 +0800
Subject: [PATCH] update
---
src/Arknights-tools/coin.py | 61 ++++++++++++
src/Arknights-tools/templates/index.html | 117 +++++++++++++++++++++++
src/multi_agent/config.py | 34 +++++++
src/multi_agent/hierarchical_demo.py | 3 +
src/utils/mp4_metadata.py | 55 +++++++++++
src/utils/vtt.py | 15 +++
6 files changed, 285 insertions(+)
create mode 100644 src/Arknights-tools/coin.py
create mode 100644 src/Arknights-tools/templates/index.html
create mode 100644 src/utils/mp4_metadata.py
create mode 100644 src/utils/vtt.py
diff --git a/src/Arknights-tools/coin.py b/src/Arknights-tools/coin.py
new file mode 100644
index 0000000..782fa6d
--- /dev/null
+++ b/src/Arknights-tools/coin.py
@@ -0,0 +1,61 @@
+from flask import Flask, render_template, request, jsonify
+from itertools import combinations
+
+app = Flask(__name__)
+
+
+# 钱币有且只有“花”“衡”“厉”三个种类。
+# 盒子里有三个种类的钱币若干枚,由用户输入每种钱币的数量box。
+# 通过排列组合原理计算:从盒子中任意取出pick枚钱币时,取出的钱币数量满足requirement的概率。
+# 函数输入:
+# box: (1, 2, 3) 分别是盒子中花、衡、厉三种钱的数量。
+# requirement: ((0, 3),(0, 3),(0, 3)),分别时掷出的钱中花、衡、厉三种钱的最少、最多数量。
+# pick: 3,从盒子中取出钱币的数量。
+
+def calculate_probability(box, requirement, pick):
+ total_coins = sum(box)
+ if pick > total_coins:
+ return 0.0
+
+ # 生成所有可能的组合
+ coins = ['H'] * box[0] + ['E'] * box[1] + ['L'] * box[2]
+
+ valid_combinations = 0
+ all_combinations = list(combinations(coins, pick))
+
+ for combo in all_combinations:
+ count_H = combo.count('H')
+ count_E = combo.count('E')
+ count_L = combo.count('L')
+
+ if (requirement[0][0] <= count_H <= requirement[0][1] and
+ requirement[1][0] <= count_E <= requirement[1][1] and
+ requirement[2][0] <= count_L <= requirement[2][1]):
+ valid_combinations += 1
+
+ probability = valid_combinations / len(all_combinations)
+ return probability
+
+
+@app.route('/', methods=['GET', 'POST'])
+def index():
+ if request.method == 'POST':
+ box = tuple(map(int, request.form['box'].split(',')))
+ requirement = tuple(tuple(map(int, req.split(','))) for req in request.form['requirement'].split(';'))
+ pick = int(request.form['pick'])
+
+ probability = calculate_probability(box, requirement, pick)
+ return jsonify({'probability': probability})
+
+ return render_template('index.html')
+
+
+if __name__ == '__main__':
+ app.run(port=5001)
+
+# Example usage:
+# if __name__ == "__main__":
+# box = (1, 4, 2)
+# requirement = ((0, 3), (0, 3), (1, 3))
+# pick = 3
+# print(calculate_probability(box, requirement, pick))
diff --git a/src/Arknights-tools/templates/index.html b/src/Arknights-tools/templates/index.html
new file mode 100644
index 0000000..32aa872
--- /dev/null
+++ b/src/Arknights-tools/templates/index.html
@@ -0,0 +1,117 @@
+
+
+
+
+
+ 界园投币概率计算器
+
+
+
+
+钱币概率计算器
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/multi_agent/config.py b/src/multi_agent/config.py
index 78ca965..0a61739 100644
--- a/src/multi_agent/config.py
+++ b/src/multi_agent/config.py
@@ -8,3 +8,37 @@ LLM = ChatOllama(model='qwen2.5:14b', api_key="1145141919810", base_url='http://
tavily_key = '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'
gaode_key = '00fd082df2414f75c6efb64896819451'
+
+#
+#
+# import requests
+#
+# url = 'http://192.168.195.158:61000/LLMProcessStream'
+# json = {
+# "conversation_id": "49fcf90889cb5538d6171cc5043537cd",
+# "model": "qwen2.5:14b",
+# "user_input": "Good day",
+# "require_voice": False,
+# "rag": False
+# }
+#
+# headers = {'Authorization': '9a504ac370734c811d107b2f634185b0', 'user': "armor"}
+# response = requests.post(url, json=json, headers=headers, stream=True)
+#
+# result_str = ''
+# flag = True
+# for i in response:
+# target = i.decode('utf-8')
+# if '<1json2>' not in target:
+# pass
+# else:
+# flag = False
+# if flag:
+# print(target, end='')
+# if not flag:
+# result_str += target
+# result_str = result_str.replace('<1json2>', '')
+# print('')
+# print(result_str)
+
+
diff --git a/src/multi_agent/hierarchical_demo.py b/src/multi_agent/hierarchical_demo.py
index 1bd4dc2..548b969 100644
--- a/src/multi_agent/hierarchical_demo.py
+++ b/src/multi_agent/hierarchical_demo.py
@@ -185,6 +185,9 @@ if '__main__' == __name__:
print(s)
print('-'*80)
+ import datetime
+ print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
+
diff --git a/src/utils/mp4_metadata.py b/src/utils/mp4_metadata.py
new file mode 100644
index 0000000..bb55c99
--- /dev/null
+++ b/src/utils/mp4_metadata.py
@@ -0,0 +1,55 @@
+import struct
+
+def read_uint32(data, offset):
+ return struct.unpack('>I', data[offset:offset+4])[0]
+
+def patch_duration(data, box_type, new_duration_sec, start=0, end=None):
+ if end is None:
+ end = len(data)
+ offset = start
+ while offset < end:
+ if offset + 8 > len(data):
+ break
+ size = read_uint32(data, offset)
+ if size < 8:
+ break
+ typ = data[offset+4:offset+8]
+ if typ == box_type:
+ version = data[offset+8]
+ if version == 0:
+ timescale_offset = offset+20
+ duration_offset = offset+24
+ timescale = read_uint32(data, timescale_offset)
+ # 如果 timescale 异常大,强制修正
+ if timescale > 100000:
+ print(f'{box_type.decode()} timescale异常({timescale}),强制设为1000')
+ timescale = 1000
+ data[timescale_offset:timescale_offset+4] = struct.pack('>I', timescale)
+ new_duration = int(new_duration_sec * timescale)
+ if not (0 <= new_duration <= 0xFFFFFFFF):
+ print(f'{box_type.decode()} duration超出范围,使用最大值')
+ new_duration = 0xFFFFFFFF
+ data[duration_offset:duration_offset+4] = struct.pack('>I', new_duration)
+ print(f'已修正{box_type.decode()} duration: {new_duration} (timescale={timescale})')
+ else:
+ print(f'{box_type.decode()} 暂不支持 version 1')
+ # 递归 container box
+ if typ in [b'moov', b'trak', b'mdia']:
+ patch_duration(data, box_type, new_duration_sec, offset+8, offset+size)
+ offset += size if size > 0 else 8
+
+def fix_mp4_duration(file_path, output_path, new_duration_sec):
+ with open(file_path, 'rb') as f:
+ data = bytearray(f.read())
+ for box in [b'mvhd', b'tkhd', b'mdhd']:
+ patch_duration(data, box, new_duration_sec)
+ with open(output_path, 'wb') as f:
+ f.write(data)
+ print('修复完成,请检查时长')
+
+if __name__ == '__main__':
+ fix_mp4_duration(
+ r'C:\Users\26549\Downloads\Video\1.mp4',
+ r'C:\Users\26549\Downloads\Video\1_fixed.mp4',
+ 7200
+ )
\ No newline at end of file
diff --git a/src/utils/vtt.py b/src/utils/vtt.py
new file mode 100644
index 0000000..a0844b6
--- /dev/null
+++ b/src/utils/vtt.py
@@ -0,0 +1,15 @@
+import whisper
+import os
+
+# 加载Whisper模型(可选"base"、"small"、"medium"、"large")
+model = whisper.load_model("medium")
+
+path = r'C:\Users\26549\OneDrive\工作\北电数智科技\EV\250701_1318.m4a'
+print(os.path.exists(path))
+
+# 读取并转写m4a音频文件
+result = model.transcribe(audio=path, language="zh")
+
+# 输出转写结果
+print(result["text"])
+print('done')