Skip to content

Commit 2ef0822

Browse files
authored
Update asr_component.py
1 parent 1e771be commit 2ef0822

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

education-ai-suite/smart-classroom/components/asr_component.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ def process(self, input_generator):
187187
if os.path.exists(chunk_path) and DELETE_CHUNK_AFTER_USE:
188188
os.remove(chunk_path)
189189

190-
StorageManager.save_async(transcript_path, transcribed_text, append=True)
191-
192190
yield {
193191
**chunk_data,
194192
"text": transcribed_text,
@@ -208,8 +206,9 @@ def process(self, input_generator):
208206
teacher_speaker = max(self.speaker_text_len, key=self.speaker_text_len.get)
209207

210208
if teacher_speaker:
211-
teacher_lines_with_time = []
209+
teacher_lines = []
212210
full_updated_lines = []
211+
full_timestamped_lines = []
213212

214213
for seg in self.all_segments:
215214
spk = seg["speaker"]
@@ -219,8 +218,8 @@ def process(self, input_generator):
219218

220219
if spk == teacher_speaker:
221220
speaker_label = LABEL_TEACHER
222-
teacher_lines_with_time.append(
223-
f"[{start} - {end}] {speaker_label}: {text}"
221+
teacher_lines.append(
222+
f"{text}"
224223
)
225224
else:
226225
if spk.startswith(f"{LABEL_SPEAKER}_"):
@@ -233,7 +232,11 @@ def process(self, input_generator):
233232
speaker_label = spk
234233

235234
full_updated_lines.append(
236-
f"[{start} - {end}] {speaker_label}: {text}"
235+
f"{speaker_label}: {text}"
236+
)
237+
238+
full_timestamped_lines.append(
239+
f"[{start} - {end}]: {text}"
237240
)
238241

239242
StorageManager.save(
@@ -242,9 +245,15 @@ def process(self, input_generator):
242245
append=False
243246
)
244247

248+
StorageManager.save(
249+
os.path.join(project_path, "content_segmentation_transcription.txt"),
250+
"\n".join(full_timestamped_lines) + "\n",
251+
append=False
252+
)
253+
245254
StorageManager.save(
246255
os.path.join(project_path, "teacher_transcription.txt"),
247-
"\n".join(teacher_lines_with_time) + "\n",
256+
"\n".join(teacher_lines) + "\n",
248257
append=False
249258
)
250259

@@ -269,4 +278,4 @@ def process(self, input_generator):
269278
}
270279
)
271280

272-
logger.info(f"Transcription Complete: {self.session_id}")
281+
logger.info(f"Transcription Complete: {self.session_id}")

0 commit comments

Comments
 (0)