${sentences.map((sent, si) => {
const startOffset = (acc / totalWords) * paraDuration;
acc += wordCounts[si];
const sentenceDuration = (wordCounts[si] / totalWords) * paraDuration;
const endOffset = si < sentences.length - 1 ? startOffset + sentenceDuration - 0.001 : paraEnd - paraStart;
const spanStart = paraStart + startOffset;
const spanEnd = paraStart + endOffset;
return html`${sent}${si < sentences.length - 1 ? ' ' : ''}`;
})}
`;
});
return html`${paragraphs}`;
}
override render() {
return html`
(this.shadowRoot?.querySelector(".file-input") as HTMLInputElement)?.click() : null}>
🎵
${
!this.serviceAvailable
? "Transcription service unavailable"
: this.isUploading
? "Uploading..."
: "Drop audio file here or click to browse"
}
${this.serviceAvailable ? "Supports MP3, WAV, M4A, AAC, OGG, WebM, FLAC up to 100MB" : "Transcription is currently unavailable"}
Your Transcriptions
${this.jobs.map(
(job) => html`
${
job.status === "uploading" ||
job.status === "processing" ||
job.status === "transcribing"
? html`
`
: ""
}
${
job.status === "completed" && job.audioUrl && job.vttSegments
? html`
${this.renderTranscript(job)}
`
: this.displayedTranscripts.has(job.id) && this.displayedTranscripts.get(job.id)
? html`
${this.renderTranscript(job)}
`
: ""
}
`,
)}
`;
}
}