(transcript: TranscriptSegment[])
| 259 | } |
| 260 | |
| 261 | function createFallbackSegment(transcript: TranscriptSegment[]): TopicSegment | null { |
| 262 | if (!transcript.length) return null; |
| 263 | |
| 264 | const startSegment = transcript[0]; |
| 265 | let endIdx = 0; |
| 266 | let endTime = startSegment.start; |
| 267 | |
| 268 | for (let i = 0; i < transcript.length; i++) { |
| 269 | endIdx = i; |
| 270 | endTime = transcript[i].start + transcript[i].duration; |
| 271 | if (endTime - startSegment.start >= 60) { |
| 272 | break; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | const combinedText = transcript |
| 277 | .slice(0, endIdx + 1) |
| 278 | .map((segment) => segment.text) |
| 279 | .join(' ') |
| 280 | .trim(); |
| 281 | |
| 282 | return { |
| 283 | start: startSegment.start, |
| 284 | end: endTime, |
| 285 | text: combinedText, |
| 286 | startSegmentIdx: 0, |
| 287 | endSegmentIdx: endIdx, |
| 288 | startCharOffset: 0, |
| 289 | endCharOffset: transcript[endIdx].text.length, |
| 290 | hasCompleteSentences: false, |
| 291 | }; |
| 292 | } |
| 293 | |
| 294 | function ensureTranscriptIndex( |
| 295 | existingIndex: TranscriptIndex | null, |
no outgoing calls
no test coverage detected