vyluong commited on
Commit
643c8eb
·
verified ·
1 Parent(s): 6f1a9a9

Update app/api/routes.py

Browse files
Files changed (1) hide show
  1. app/api/routes.py +18 -7
app/api/routes.py CHANGED
@@ -119,20 +119,31 @@ async def transcribe_audio(
119
  background_tasks.add_task(cleanup_files, upload_path)
120
 
121
  # Build response
122
- return TranscriptionResponse(
123
- success=True,
124
- segments=[
 
 
 
 
 
 
 
 
125
  {
126
  "start": seg.start,
127
  "end": seg.end,
128
  "speaker": seg.speaker,
129
  "role": seg.role,
130
  "text": seg.text,
131
- "emotion": seg.emotion if seg.role == "KH" else None,
132
- "icon": seg.icon if seg.icon == "KH" else None
133
  }
134
- for seg in result.segments
135
- ],
 
 
 
136
  speaker_count=result.speaker_count,
137
  speakers=result.speakers,
138
  duration=result.duration,
 
119
  background_tasks.add_task(cleanup_files, upload_path)
120
 
121
  # Build response
122
+ segments = []
123
+
124
+ for seg in result.segments:
125
+ if seg.role == "KH":
126
+ emotion = seg.emotion
127
+ icon = seg.icon
128
+ else:
129
+ emotion = None
130
+ icon = None
131
+
132
+ segments.append(
133
  {
134
  "start": seg.start,
135
  "end": seg.end,
136
  "speaker": seg.speaker,
137
  "role": seg.role,
138
  "text": seg.text,
139
+ "emotion": emotion,
140
+ "icon": icon,
141
  }
142
+ )
143
+
144
+ return TranscriptionResponse(
145
+ success=True,
146
+ segments=segments,
147
  speaker_count=result.speaker_count,
148
  speakers=result.speakers,
149
  duration=result.duration,