Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,7 @@ transcription = TranscriptionMaker()
|
|
| 11 |
app = Flask(__name__)
|
| 12 |
|
| 13 |
users = []
|
|
|
|
| 14 |
|
| 15 |
# トップページ(テンプレート: index.html)
|
| 16 |
@app.route('/')
|
|
@@ -23,7 +24,6 @@ def index():
|
|
| 23 |
def feedback():
|
| 24 |
return render_template('feedback.html')
|
| 25 |
|
| 26 |
-
|
| 27 |
# 会話詳細画面(テンプレート: talkDetail.html)
|
| 28 |
@app.route('/talk_detail', methods=['GET', 'POST'])
|
| 29 |
def talk_detail():
|
|
@@ -38,11 +38,17 @@ def userregister():
|
|
| 38 |
def confirm():
|
| 39 |
return jsonify({'members': users}), 200
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# 音声アップロード&解析エンドポイント
|
| 44 |
@app.route('/upload_audio', methods=['POST'])
|
| 45 |
def upload_audio():
|
|
|
|
| 46 |
try:
|
| 47 |
data = request.get_json()
|
| 48 |
# name か users のいずれかが必須。どちらも無い場合はエラー
|
|
@@ -74,10 +80,8 @@ def upload_audio():
|
|
| 74 |
if len(users) > 1:
|
| 75 |
print("複数人の場合の処理")
|
| 76 |
matched_time, unmatched_time,segments_dir = process.process_multi_audio(reference_paths, audio_path, threshold=0.05)
|
| 77 |
-
transcription.create_transcription(segments_dir)
|
| 78 |
else:
|
| 79 |
-
matched_time, unmatched_time,
|
| 80 |
-
transcription.create_transcription(matched_segments_dir)
|
| 81 |
|
| 82 |
total_time = matched_time + unmatched_time
|
| 83 |
rate = (matched_time / total_time) * 100 if total_time > 0 else 0
|
|
|
|
| 11 |
app = Flask(__name__)
|
| 12 |
|
| 13 |
users = []
|
| 14 |
+
segments_dir
|
| 15 |
|
| 16 |
# トップページ(テンプレート: index.html)
|
| 17 |
@app.route('/')
|
|
|
|
| 24 |
def feedback():
|
| 25 |
return render_template('feedback.html')
|
| 26 |
|
|
|
|
| 27 |
# 会話詳細画面(テンプレート: talkDetail.html)
|
| 28 |
@app.route('/talk_detail', methods=['GET', 'POST'])
|
| 29 |
def talk_detail():
|
|
|
|
| 38 |
def confirm():
|
| 39 |
return jsonify({'members': users}), 200
|
| 40 |
|
| 41 |
+
# 書き起こし作成エンドポイント
|
| 42 |
+
@app.route('/transcription',methods =['GET','POST'])
|
| 43 |
+
def transcription():
|
| 44 |
+
global segments_dir
|
| 45 |
+
text = transcription.create_transcription(segments_dir)
|
| 46 |
+
return jsonify({'transcription': text}),200
|
| 47 |
|
| 48 |
# 音声アップロード&解析エンドポイント
|
| 49 |
@app.route('/upload_audio', methods=['POST'])
|
| 50 |
def upload_audio():
|
| 51 |
+
global segments_dir
|
| 52 |
try:
|
| 53 |
data = request.get_json()
|
| 54 |
# name か users のいずれかが必須。どちらも無い場合はエラー
|
|
|
|
| 80 |
if len(users) > 1:
|
| 81 |
print("複数人の場合の処理")
|
| 82 |
matched_time, unmatched_time,segments_dir = process.process_multi_audio(reference_paths, audio_path, threshold=0.05)
|
|
|
|
| 83 |
else:
|
| 84 |
+
matched_time, unmatched_time, segments_dir = process.process_audio(reference_paths[0], audio_path, threshold=0.05)
|
|
|
|
| 85 |
|
| 86 |
total_time = matched_time + unmatched_time
|
| 87 |
rate = (matched_time / total_time) * 100 if total_time > 0 else 0
|