Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Add transcript download button with raw export option

Murtaza Nasirb4641f002891
diff --git a/static/js/app.js b/static/js/app.js
index f6b69310..5344a6f7 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -4219,7 +4219,7 @@ document.addEventListener('DOMContentLoaded', async () => {
});
modal.querySelector('.download-without-template-btn').addEventListener('click', () => {
- templateId = null;
+ templateId = 'none'; // Use 'none' to indicate no template
modal.remove();
resolve();
});
@@ -4238,6 +4238,40 @@ document.addEventListener('DOMContentLoaded', async () => {
}
}
+ // If templateId is 'none', download raw transcript without any template
+ if (templateId === 'none') {
+ // Create raw transcript text
+ let rawText = '';
+ try {
+ const transcriptionData = JSON.parse(selectedRecording.value.transcription);
+ if (Array.isArray(transcriptionData)) {
+ rawText = transcriptionData.map(segment => {
+ const speaker = segment.speaker || 'Unknown';
+ const text = segment.sentence || '';
+ return `${speaker}: ${text}`;
+ }).join('\n');
+ } else {
+ rawText = selectedRecording.value.transcription;
+ }
+ } catch (e) {
+ rawText = selectedRecording.value.transcription;
+ }
+
+ // Create and download the file directly
+ const blob = new Blob([rawText], { type: 'text/plain;charset=utf-8' });
+ const downloadUrl = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = downloadUrl;
+ a.download = `${selectedRecording.value.title || 'transcript'}_raw.txt`;
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(downloadUrl);
+
+ showToast('Transcript downloaded successfully!');
+ return;
+ }
+
// Download the transcript with the selected template
const url = templateId
? `/recording/${selectedRecording.value.id}/download/transcript?template_id=${templateId}`
diff --git a/static/locales/de.json b/static/locales/de.json
index 770c826a..f620b746 100644
--- a/static/locales/de.json
+++ b/static/locales/de.json
@@ -806,6 +806,7 @@
"simple": "Einfach",
"bubble": "Blase",
"copy": "Kopieren",
+ "download": "Herunterladen",
"edit": "Bearbeiten",
"cancelEdit": "Bearbeitung abbrechen",
"copyToClipboard": "In Zwischenablage kopieren",
diff --git a/static/locales/en.json b/static/locales/en.json
index 579e8089..d8124e3e 100644
--- a/static/locales/en.json
+++ b/static/locales/en.json
@@ -818,6 +818,7 @@
"simple": "Simple",
"bubble": "Bubble",
"copy": "Copy",
+ "download": "Download",
"edit": "Edit",
"cancelEdit": "Cancel Edit",
"copyToClipboard": "Copy to Clipboard",
diff --git a/static/locales/es.json b/static/locales/es.json
index a0214033..3c4c646a 100644
--- a/static/locales/es.json
+++ b/static/locales/es.json
@@ -806,6 +806,7 @@
"simple": "Simple",
"bubble": "Burbuja",
"copy": "Copiar",
+ "download": "Descargar",
"edit": "Editar",
"cancelEdit": "Cancelar Edición",
"copyToClipboard": "Copiar al Portapapeles",
diff --git a/static/locales/fr.json b/static/locales/fr.json
index 737d74b0..9493ab2f 100644
--- a/static/locales/fr.json
+++ b/static/locales/fr.json
@@ -806,6 +806,7 @@
"simple": "Simple",
"bubble": "Bulle",
"copy": "Copier",
+ "download": "Télécharger",
"edit": "Éditer",
"cancelEdit": "Annuler la Modification",
"copyToClipboard": "Copier dans le Presse-papiers",
diff --git a/static/locales/zh.json b/static/locales/zh.json
index 1b14c7b8..d35d5634 100644
--- a/static/locales/zh.json
+++ b/static/locales/zh.json
@@ -944,6 +944,7 @@
"simple": "简单",
"bubble": "气泡",
"copy": "复制",
+ "download": "下载",
"edit": "编辑",
"cancelEdit": "取消编辑",
"copyToClipboard": "复制到剪贴板",
diff --git a/templates/account.html b/templates/account.html
index 583ee9b1..d98c6ba5 100644
--- a/templates/account.html
+++ b/templates/account.html
@@ -180,6 +180,58 @@
applyTheme();
</script>
<style>
+ /* Make the page take full height */
+ html, body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+ }
+
+ /* Container layout for full height */
+ .main-container {
+ min-height: 100vh;
+ display: flex;
+ flex-direction: column;
+ }
+
+ /* Tab content area with fixed height and scrolling */
+ .tab-content-wrapper {
+ height: calc(100vh - 280px); /* Adjust based on header and tab nav height */
+ overflow-y: auto;
+ overflow-x: hidden;
+ }
+
+ @media (max-width: 640px) {
+ .tab-content-wrapper {
+ height: calc(100vh - 320px); /* Slightly less height on mobile */
+ }
+ }
+
+ /* Ensure all tab content divs take full height */
+ .tab-content {
+ min-height: 100%;
+ display: flex;
+ flex-direction: column;
+ }
+
+ /* Custom scrollbar for content areas */
+ .tab-content-wrapper::-webkit-scrollbar {
+ width: 8px;
+ }
+
+ .tab-content-wrapper::-webkit-scrollbar-track {
+ background: transparent;
+ }
+
+ .tab-content-wrapper::-webkit-scrollbar-thumb {
+ background-color: var(--border-secondary);
+ border-radius: 4px;
+ }
+
+ .tab-content-wrapper::-webkit-scrollbar-thumb:hover {
+ background-color: var(--border-accent);
+ }
+
/* Horizontal scrollbar for tab navigation */
.tab-nav {
scrollbar-width: thin;
@@ -265,7 +317,7 @@
</style>
</head>
<body class="bg-[var(--bg-primary)] text-[var(--text-primary)]">
- <div class="container mx-auto px-4 sm:px-6 lg:px-8 py-6 flex flex-col min-h-screen">
+ <div class="main-container container mx-auto px-4 sm:px-6 lg:px-8 py-6">
<header class="flex justify-between items-center mb-6 pb-4 border-b border-[var(--border-primary)]">
<h1 class="text-3xl font-bold text-[var(--text-primary)]">
<a href="{{ url_for('index') }}" class="flex items-center">
@@ -303,9 +355,9 @@
</div>
</header>
- <main class="flex-grow">
- <div class="bg-[var(--bg-secondary)] p-4 sm:p-6 lg:p-8 rounded-xl shadow-lg border border-[var(--border-primary)]">
- <div class="mb-6 border-b border-[var(--border-primary)] sm:border-b">
+ <main class="flex-grow flex flex-col">
+ <div class="bg-[var(--bg-secondary)] rounded-xl shadow-lg border border-[var(--border-primary)] flex flex-col flex-grow">
+ <div class="px-4 sm:px-6 lg:px-8 pt-4 sm:pt-6 lg:pt-8 pb-6 border-b border-[var(--border-primary)]">
<div class="relative">
<nav class="tab-nav -mb-px flex overflow-x-auto scrollbar-thin scrollbar-thumb-[var(--border-secondary)] scrollbar-track-transparent" aria-label="Tabs" style="scrollbar-width: thin;">
<div class="flex flex-col sm:flex-row sm:space-x-4 min-w-full sm:min-w-0">
@@ -335,7 +387,8 @@
</div>
</div>
- <div id="content-account">
+ <div class="tab-content-wrapper px-4 sm:px-6 lg:px-8 pb-4 sm:pb-6 lg:pb-8">
+ <div id="content-account" class="tab-content">
<h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-6" data-i18n="account.title">Account Information</h2>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
@@ -470,7 +523,7 @@
</div>
</div>
- <div id="content-prompts" class="hidden">
+ <div id="content-prompts" class="hidden tab-content">
<h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-6" data-i18n="accountTabs.customPrompts">Custom Prompts</h2>
<form id="customPromptsForm" method="POST" action="{{ url_for('account') }}" class="space-y-6">
@@ -529,14 +582,14 @@
</form>
</div>
- <div id="content-shares" class="hidden">
+ <div id="content-shares" class="hidden tab-content">
<h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-6" data-i18n="accountTabs.sharedTranscripts">My Shared Transcripts</h2>
<div id="shares-container" class="space-y-4">
<!-- Shares will be loaded here by JavaScript -->
</div>
</div>
- <div id="content-speakers" class="hidden flex flex-col h-full" style="max-height: calc(100vh - 280px);">
+ <div id="content-speakers" class="hidden tab-content">
<div class="flex-shrink-0">
<h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-4" data-i18n="accountTabs.speakersManagement">Speakers Management</h2>
<p class="text-[var(--text-secondary)] mb-4" data-i18n="speakersManagement.description">Manage your saved speakers. These are automatically saved when you use speaker names in your recordings.</p>
@@ -581,7 +634,7 @@
</div>
</div>
- <div id="content-tags" class="hidden">
+ <div id="content-tags" class="hidden tab-content">
<h2 class="text-2xl font-semibold text-[var(--text-primary)] mb-6" data-i18n="accountTabs.tagManagement">Tag Management</h2>
<div class="mb-6">
@@ -618,7 +671,7 @@
</div>
</div>
- <div id="content-templates" class="hidden">
+ <div id="content-templates" class="hidden tab-content">
<div class="space-y-6">
<!-- Templates Header -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
@@ -711,7 +764,7 @@
</div>
</div>
- <div id="content-about" class="hidden">
+ <div id="content-about" class="hidden tab-content">
<div class="space-y-8">
<!-- Header Section -->
<div class="text-center">
@@ -930,6 +983,7 @@
</div>
</div>
</div>
+ </div>
</div>
</div>
</main>
diff --git a/templates/index.html b/templates/index.html
index 5f54e726..2a114da2 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -980,7 +980,7 @@
<button @click="toggleTranscriptionViewMode" :class="['toggle-button', transcriptionViewMode === 'bubble' ? 'active' : '']"><i class="fas fa-comments"></i></button>
</div>
<button @click="copyTranscription" class="copy-btn" title="Copy transcript"><i class="fas fa-copy"></i></button>
- <button @click="downloadTranscript" class="copy-btn" title="Download transcript with template"><i class="fas fa-download"></i></button>
+ <button @click="downloadTranscript" v-if="selectedRecording && selectedRecording.transcription" class="copy-btn" title="Download transcript with template"><i class="fas fa-download"></i></button>
<button @click="openTranscriptionEditor" v-if="selectedRecording && selectedRecording.transcription" class="copy-btn" title="Edit transcript"><i class="fas fa-edit"></i></button>
</div>
<div class="flex-grow overflow-y-auto mobile-content-box">
@@ -1282,10 +1282,17 @@
</div>
<!-- Copy Button -->
- <button @click="copyTranscription"
+ <button @click="copyTranscription"
class="copy-btn">
<i class="fas fa-copy mr-1"></i><span v-text="t('transcription.copy')"></span>
</button>
+ <!-- Download Button -->
+ <button @click="downloadTranscript"
+ v-if="selectedRecording && selectedRecording.transcription"
+ class="copy-btn"
+ title="Download transcript with template">
+ <i class="fas fa-download mr-1"></i><span v-text="t('transcription.download')"></span>
+ </button>
<!-- Edit Transcription Button -->
<button @click="openTranscriptionEditor"
v-if="selectedRecording && selectedRecording.transcription"