Spaces:
Sleeping
Sleeping
Commit
·
d2bb844
1
Parent(s):
598fc2d
Update app/api/transcribe.py
Browse files- 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 |
-
|
| 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 |
-
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
info2 = get_audio_info(tmp_wav) or {}
|
| 118 |
# persist to Note Service (async HTTP)
|
| 119 |
-
|
| 120 |
-
note_id
|
| 121 |
-
raw_text
|
| 122 |
-
normalized_text
|
| 123 |
-
keywords
|
| 124 |
-
summary
|
| 125 |
-
mindmap
|
| 126 |
-
duration
|
| 127 |
-
sample_rate
|
| 128 |
-
chunks
|
| 129 |
-
asr_model
|
| 130 |
-
normalization_model
|
| 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 |
-
|
| 244 |
-
|
|
|
|
| 245 |
|
| 246 |
# 5. Persist to Note Service
|
| 247 |
-
|
| 248 |
-
note_id
|
| 249 |
-
raw_text
|
| 250 |
-
normalized_text
|
| 251 |
-
keywords
|
| 252 |
-
summary
|
| 253 |
-
mindmap
|
| 254 |
-
duration
|
| 255 |
-
sample_rate
|
| 256 |
-
chunks
|
| 257 |
-
asr_model
|
| 258 |
-
normalization_model
|
| 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(
|