buletomato25 commited on
Commit
bcd0f4a
·
1 Parent(s): 9d373c7
Files changed (1) hide show
  1. app.py +0 -33
app.py CHANGED
@@ -261,39 +261,6 @@ def upload_base_audio():
261
  print("Error in /upload_base_audio:", str(e))
262
  return jsonify({"error": "サーバーエラー", "details": str(e)}), 500
263
 
264
- @app.route('/upload_audio', methods=['POST'])
265
- def upload_audio():
266
- try:
267
- if 'name' not in session:
268
- return jsonify({"error": "ユーザーが認証されていません"}), 401
269
-
270
- data = request.get_json()
271
- if not data or 'audio_data' not in data:
272
- return jsonify({"error": "音声データがありません"}), 400
273
-
274
- # Base64デコードして音声バイナリを取得
275
- audio_binary = base64.b64decode(data['audio_data'])
276
-
277
- # ユーザー名を取得してファイル名を作成
278
- user_name = session['name']
279
- sanitized_name = "".join(c for c in user_name if c.isalnum()) # 特殊文字を除去
280
- audio_filename = f"{sanitized_name}.wav"
281
-
282
- # 保存ディレクトリを設定
283
- audio_dir = "record_data"
284
- os.makedirs(audio_dir, exist_ok=True)
285
- audio_path = os.path.join(audio_dir, audio_filename)
286
-
287
- # 音声データをファイルに保存
288
- with open(audio_path, 'wb') as f:
289
- f.write(audio_binary)
290
-
291
- print(f"音声データを {audio_path} に保存しました。")
292
-
293
- return jsonify({"success": True, "message": f"音声が {audio_filename} に保存されました。"}), 200
294
- except Exception as e:
295
- print("Error in /upload_audio:", str(e))
296
- return jsonify({"error": "サーバーエラー", "details": str(e)}), 500
297
 
298
 
299
  if __name__ == '__main__':
 
261
  print("Error in /upload_base_audio:", str(e))
262
  return jsonify({"error": "サーバーエラー", "details": str(e)}), 500
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
 
265
 
266
  if __name__ == '__main__':