bichnhan2701 commited on
Commit
d2bb844
·
1 Parent(s): 598fc2d

Update app/api/transcribe.py

Browse files
Files changed (1) hide show
  1. app/api/transcribe.py +35 -32
app/api/transcribe.py CHANGED
@@ -12,8 +12,7 @@ from app.core.asr_engine import load_model, transcribe_file, transcribe_file_chu
12
  from app.config import settings
13
  from app.services.text_normalizer import normalize_text
14
  from app.services.nlp_postprocess import normalize_and_extract
15
- from app.services.summary_service import generate_summary
16
- from app.services.mindmap_service import generate_mindmap
17
  from app.services.note_client import NoteServiceClient
18
  from rq import Queue
19
  from app.infra.redis_client import redis_client
@@ -111,24 +110,26 @@ async def transcribe(file: UploadFile = File(...)):
111
  normalized_text = nlp["normalized_text"]
112
  keywords = nlp["keywords"]
113
 
114
- summary = await generate_summary(normalized_text)
115
- mindmap = await generate_mindmap(normalized_text)
 
116
 
117
  info2 = get_audio_info(tmp_wav) or {}
118
  # persist to Note Service (async HTTP)
119
- await note_service.save_transcript(
120
- note_id=note_id,
121
- raw_text=text,
122
- normalized_text=normalized_text,
123
- keywords=keywords,
124
- summary=summary,
125
- mindmap=mindmap,
126
- duration=info2.get("duration"),
127
- sample_rate=info2.get("samplerate"),
128
- chunks=chunks,
129
- asr_model="PhoWhisper-base",
130
- normalization_model="gemini-1.5",
131
- )
 
132
 
133
  duration = time.perf_counter() - start_time
134
  logging.info(f"/transcribe success note_id={note_id} duration={duration:.2f}s audio_dur={info2.get('duration')}")
@@ -240,23 +241,25 @@ async def transcribe_url(payload: dict):
240
  normalized_text = nlp["normalized_text"]
241
  keywords = nlp["keywords"]
242
 
243
- summary = await generate_summary(normalized_text)
244
- mindmap = await generate_mindmap(normalized_text)
 
245
 
246
  # 5. Persist to Note Service
247
- await note_service.save_transcript(
248
- note_id=note_id,
249
- raw_text=text,
250
- normalized_text=normalized_text,
251
- keywords=keywords,
252
- summary=summary,
253
- mindmap=mindmap,
254
- duration=info.get("duration"),
255
- sample_rate=info.get("samplerate"),
256
- chunks=chunks,
257
- asr_model="PhoWhisper-base",
258
- normalization_model="gemini-1.5",
259
- )
 
260
 
261
  duration = time.perf_counter() - start_time
262
  logging.info(
 
12
  from app.config import settings
13
  from app.services.text_normalizer import normalize_text
14
  from app.services.nlp_postprocess import normalize_and_extract
15
+ # Summary and mindmap generation moved to Note Service; do not import here
 
16
  from app.services.note_client import NoteServiceClient
17
  from rq import Queue
18
  from app.infra.redis_client import redis_client
 
110
  normalized_text = nlp["normalized_text"]
111
  keywords = nlp["keywords"]
112
 
113
+ # Summary / mindmap are generated by the Note Service; omit local generation
114
+ summary = None
115
+ mindmap = None
116
 
117
  info2 = get_audio_info(tmp_wav) or {}
118
  # persist to Note Service (async HTTP)
119
+ payload = {
120
+ "note_id": note_id,
121
+ "raw_text": text,
122
+ "normalized_text": normalized_text,
123
+ "keywords": keywords,
124
+ "summary": summary,
125
+ "mindmap": mindmap,
126
+ "duration": info2.get("duration"),
127
+ "sample_rate": info2.get("samplerate"),
128
+ "chunks": chunks,
129
+ "asr_model": "PhoWhisper-base",
130
+ "normalization_model": "gemini-1.5",
131
+ }
132
+ await note_service.save_transcript(payload)
133
 
134
  duration = time.perf_counter() - start_time
135
  logging.info(f"/transcribe success note_id={note_id} duration={duration:.2f}s audio_dur={info2.get('duration')}")
 
241
  normalized_text = nlp["normalized_text"]
242
  keywords = nlp["keywords"]
243
 
244
+ # Summary / mindmap are generated by the Note Service; omit local generation
245
+ summary = None
246
+ mindmap = None
247
 
248
  # 5. Persist to Note Service
249
+ payload = {
250
+ "note_id": note_id,
251
+ "raw_text": text,
252
+ "normalized_text": normalized_text,
253
+ "keywords": keywords,
254
+ "summary": summary,
255
+ "mindmap": mindmap,
256
+ "duration": info.get("duration"),
257
+ "sample_rate": info.get("samplerate"),
258
+ "chunks": chunks,
259
+ "asr_model": "PhoWhisper-base",
260
+ "normalization_model": "gemini-1.5",
261
+ }
262
+ await note_service.save_transcript(payload)
263
 
264
  duration = time.perf_counter() - start_time
265
  logging.info(