bichnhan2701 commited on
Commit
65ea3a1
·
1 Parent(s): ca4e471

update transcribe job fix bug

Browse files
Files changed (1) hide show
  1. app/jobs/transcribe_job.py +5 -10
app/jobs/transcribe_job.py CHANGED
@@ -1,7 +1,6 @@
1
  import asyncio
2
  import tempfile
3
  import os
4
- from xmlrpc import client
5
  import requests
6
 
7
  from app.core.asr_engine import load_model, transcribe_file, transcribe_file_chunks
@@ -22,10 +21,10 @@ def download_audio(audio_url: str) -> str:
22
 
23
  def transcribe_job(audio_url: str, note_id: str, user_id: str | None = None):
24
  model = load_model()
25
-
26
  wav_path = None
 
27
  try:
28
- # 1️⃣ Worker tự fetch audio
29
  wav_path = download_audio(audio_url)
30
 
31
  # 2️⃣ ASR
@@ -59,17 +58,13 @@ def transcribe_job(audio_url: str, note_id: str, user_id: str | None = None):
59
  },
60
  "client": {"user_id": user_id},
61
  },
 
62
  "generate": ["normalize", "keywords", "summary", "mindmap"],
63
  }
64
 
65
  client = NoteServiceClient()
66
- asyncio.run(client.update_note(note_id, {
67
- "status": note_status,
68
- "raw_text": text,
69
- "metadata": payload["metadata"],
70
- }))
71
-
72
  finally:
73
- # 3️⃣ Cleanup
74
  if wav_path and os.path.exists(wav_path):
75
  os.remove(wav_path)
 
1
  import asyncio
2
  import tempfile
3
  import os
 
4
  import requests
5
 
6
  from app.core.asr_engine import load_model, transcribe_file, transcribe_file_chunks
 
21
 
22
  def transcribe_job(audio_url: str, note_id: str, user_id: str | None = None):
23
  model = load_model()
 
24
  wav_path = None
25
+
26
  try:
27
+ # 1️⃣ Download audio
28
  wav_path = download_audio(audio_url)
29
 
30
  # 2️⃣ ASR
 
58
  },
59
  "client": {"user_id": user_id},
60
  },
61
+ # 🔥 trigger enrich pipeline
62
  "generate": ["normalize", "keywords", "summary", "mindmap"],
63
  }
64
 
65
  client = NoteServiceClient()
66
+ asyncio.run(client.create_audio_note(payload))
67
+
 
 
 
 
68
  finally:
 
69
  if wav_path and os.path.exists(wav_path):
70
  os.remove(wav_path)