Spaces:
Running
Running
Update app.py
Browse files- __pycache__/process.cpython-310.pyc +0 -0
- app.py +3 -2
- process.py +2 -2
__pycache__/process.cpython-310.pyc
CHANGED
Binary files a/__pycache__/process.cpython-310.pyc and b/__pycache__/process.cpython-310.pyc differ
|
|
app.py
CHANGED
@@ -91,6 +91,7 @@ def analyze():
|
|
91 |
# 音声アップロード&解析エンドポイント
|
92 |
@app.route('/upload_audio', methods=['POST'])
|
93 |
def upload_audio():
|
|
|
94 |
try:
|
95 |
data = request.get_json()
|
96 |
# name か users のいずれかが必須。どちらも無い場合はエラー
|
@@ -119,13 +120,13 @@ def upload_audio():
|
|
119 |
# 複数人の場合は参照パスのリストを、1人の場合は単一のパスを渡す
|
120 |
if len(users) > 1:
|
121 |
print("複数人の場合の処理")
|
122 |
-
matched_times = process.process_multi_audio(reference_paths, audio_path, threshold=0.05)
|
123 |
# 各メンバーのrateを計算
|
124 |
total_time = sum(matched_times)
|
125 |
rates = [(time / total_time) * 100 if total_time > 0 else 0 for time in matched_times]
|
126 |
return jsonify({"rates": rates}), 200
|
127 |
else:
|
128 |
-
matched_time, unmatched_time = process.process_audio(reference_paths[0], audio_path, threshold=0.05)
|
129 |
total_time = matched_time + unmatched_time
|
130 |
rate = (matched_time / total_time) * 100 if total_time > 0 else 0
|
131 |
return jsonify({"rate": rate}), 200
|
|
|
91 |
# 音声アップロード&解析エンドポイント
|
92 |
@app.route('/upload_audio', methods=['POST'])
|
93 |
def upload_audio():
|
94 |
+
global segments_dir
|
95 |
try:
|
96 |
data = request.get_json()
|
97 |
# name か users のいずれかが必須。どちらも無い場合はエラー
|
|
|
120 |
# 複数人の場合は参照パスのリストを、1人の場合は単一のパスを渡す
|
121 |
if len(users) > 1:
|
122 |
print("複数人の場合の処理")
|
123 |
+
matched_times, segments_dir = process.process_multi_audio(reference_paths, audio_path, threshold=0.05)
|
124 |
# 各メンバーのrateを計算
|
125 |
total_time = sum(matched_times)
|
126 |
rates = [(time / total_time) * 100 if total_time > 0 else 0 for time in matched_times]
|
127 |
return jsonify({"rates": rates}), 200
|
128 |
else:
|
129 |
+
matched_time, unmatched_time, segments_dir = process.process_audio(reference_paths[0], audio_path, threshold=0.05)
|
130 |
total_time = matched_time + unmatched_time
|
131 |
rate = (matched_time / total_time) * 100 if total_time > 0 else 0
|
132 |
return jsonify({"rate": rate}), 200
|
process.py
CHANGED
@@ -89,7 +89,7 @@ class AudioProcessor():
|
|
89 |
matched_time_ms += len(AudioSegment.from_file(segment_file))
|
90 |
|
91 |
unmatched_time_ms = total_duration_ms - matched_time_ms
|
92 |
-
return matched_time_ms, unmatched_time_ms
|
93 |
|
94 |
|
95 |
def process_multi_audio(self, reference_pathes, input_path, output_folder='/tmp/data/matched_multi_segments', seg_duration=1.0, threshold=0.5):
|
@@ -141,7 +141,7 @@ class AudioProcessor():
|
|
141 |
if match is not None:
|
142 |
matched_time[match] += seg_duration
|
143 |
|
144 |
-
return matched_time
|
145 |
|
146 |
|
147 |
def save_audio_from_base64(self,base64_audio,output_dir,output_filename,temp_format='webm'):
|
|
|
89 |
matched_time_ms += len(AudioSegment.from_file(segment_file))
|
90 |
|
91 |
unmatched_time_ms = total_duration_ms - matched_time_ms
|
92 |
+
return matched_time_ms, unmatched_time_ms,output_folder
|
93 |
|
94 |
|
95 |
def process_multi_audio(self, reference_pathes, input_path, output_folder='/tmp/data/matched_multi_segments', seg_duration=1.0, threshold=0.5):
|
|
|
141 |
if match is not None:
|
142 |
matched_time[match] += seg_duration
|
143 |
|
144 |
+
return matched_time, segmented_path
|
145 |
|
146 |
|
147 |
def save_audio_from_base64(self,base64_audio,output_dir,output_filename,temp_format='webm'):
|