Skip to content

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

Python

Add incognito mode support for in-app recordings

Murtaza Nasirbdbb6aa3e9b0
diff --git a/static/js/modules/composables/audio.js b/static/js/modules/composables/audio.js
index 2b60626c..a1842215 100644
--- a/static/js/modules/composables/audio.js
+++ b/static/js/modules/composables/audio.js
@@ -4,6 +4,7 @@
*/
import * as RecordingDB from '../db/recording-persistence.js';
+import * as IncognitoStorage from '../db/incognito-storage.js';
export function useAudio(state, utils) {
const {
@@ -15,7 +16,10 @@ export function useAudio(state, utils) {
activeStreams, visualizer, micVisualizer, systemVisualizer, canRecordAudio,
canRecordSystemAudio, systemAudioSupported, systemAudioError, globalError,
selectedTagIds, asrLanguage, asrMinSpeakers, asrMaxSpeakers, uploadQueue,
- progressPopupMinimized, progressPopupClosed
+ progressPopupMinimized, progressPopupClosed,
+ // Incognito mode
+ enableIncognitoMode, incognitoMode, incognitoRecording, incognitoProcessing,
+ processingMessage, processingProgress, selectedRecording
} = state;
const { showToast, setGlobalError, formatFileSize, startUploadQueue } = utils;
@@ -543,6 +547,128 @@ export function useAudio(state, utils) {
}
};
+ // Upload recorded audio in incognito mode
+ const uploadRecordedAudioIncognito = async () => {
+ if (!audioBlobURL.value) {
+ setGlobalError("No recorded audio to upload.");
+ return;
+ }
+
+ // Check if incognito state is available
+ if (!incognitoProcessing || !incognitoRecording) {
+ console.warn('[Incognito] Incognito state not available, falling back to normal upload');
+ uploadRecordedAudio();
+ return;
+ }
+
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
+ const recordedFile = new File(audioChunks.value, `recording-${timestamp}.webm`, { type: 'audio/webm' });
+
+ incognitoProcessing.value = true;
+ processingMessage.value = 'Processing recording in incognito mode...';
+ processingProgress.value = 10;
+ progressPopupMinimized.value = false;
+ progressPopupClosed.value = false;
+
+ try {
+ const formData = new FormData();
+ formData.append('file', recordedFile);
+
+ // Add ASR options
+ if (asrLanguage.value) {
+ formData.append('language', asrLanguage.value);
+ }
+ if (asrMinSpeakers.value && asrMinSpeakers.value !== '') {
+ formData.append('min_speakers', asrMinSpeakers.value.toString());
+ }
+ if (asrMaxSpeakers.value && asrMaxSpeakers.value !== '') {
+ formData.append('max_speakers', asrMaxSpeakers.value.toString());
+ }
+
+ // Request auto-summarization
+ formData.append('auto_summarize', 'true');
+
+ processingMessage.value = 'Uploading recording for incognito processing...';
+ processingProgress.value = 20;
+
+ console.log('[Incognito] Uploading recorded audio');
+
+ const response = await fetch('/api/recordings/incognito', {
+ method: 'POST',
+ body: formData
+ });
+
+ processingProgress.value = 50;
+
+ // Parse response
+ const contentType = response.headers.get('content-type') || '';
+ if (!contentType.includes('application/json')) {
+ const text = await response.text();
+ const titleMatch = text.match(/<title>([^<]+)<\/title>/i);
+ throw new Error(titleMatch?.[1] || `Server error (${response.status})`);
+ }
+
+ const data = await response.json();
+
+ if (!response.ok || data.error) {
+ throw new Error(data.error || `Processing failed with status ${response.status}`);
+ }
+
+ processingProgress.value = 80;
+ processingMessage.value = 'Processing complete!';
+
+ // Store result in sessionStorage
+ const incognitoData = {
+ id: 'incognito',
+ incognito: true,
+ title: data.title || 'Incognito Recording',
+ transcription: data.transcription,
+ summary: data.summary,
+ summary_html: data.summary_html,
+ created_at: data.created_at,
+ original_filename: data.original_filename,
+ file_size: data.file_size,
+ audio_duration_seconds: data.audio_duration_seconds,
+ processing_time_seconds: data.processing_time_seconds,
+ status: 'COMPLETED'
+ };
+
+ IncognitoStorage.saveIncognitoRecording(incognitoData);
+ incognitoRecording.value = incognitoData;
+
+ // Clear IndexedDB session
+ try {
+ await RecordingDB.clearRecordingSession();
+ } catch (dbError) {
+ console.warn('[Recording] Failed to clear IndexedDB session:', dbError);
+ }
+
+ // Clear recording state
+ discardRecording();
+
+ processingProgress.value = 100;
+ processingMessage.value = 'Incognito recording ready!';
+
+ // Auto-select the incognito recording and switch to detail view
+ selectedRecording.value = incognitoData;
+ currentView.value = 'detail';
+
+ // Reset incognito mode toggle
+ incognitoMode.value = false;
+
+ // Show toast
+ showToast('Incognito recording processed - data will be lost when tab closes', 'fa-user-secret');
+
+ console.log('[Incognito] Recording processing complete');
+
+ } catch (error) {
+ console.error('[Incognito] Recording processing failed:', error);
+ setGlobalError(`Incognito processing failed: ${error.message}`);
+ } finally {
+ incognitoProcessing.value = false;
+ }
+ };
+
// Discard recording
const discardRecording = async () => {
if (audioBlobURL.value) {
@@ -731,6 +857,7 @@ export function useAudio(state, utils) {
stopRecording,
discardRecording,
uploadRecordedAudio,
+ uploadRecordedAudioIncognito,
acceptRecordingDisclaimer,
cancelRecordingDisclaimer,
updateFileSizeEstimate,
diff --git a/templates/components/recording-view.html b/templates/components/recording-view.html
index ec33f8c4..c57b23c8 100644
--- a/templates/components/recording-view.html
+++ b/templates/components/recording-view.html
@@ -256,13 +256,66 @@
</div>
</div>
+ <!-- Incognito Mode Toggle (only shown if feature is enabled) -->
+ <div v-if="enableIncognitoMode" class="mb-3">
+ <button @click="incognitoMode = !incognitoMode"
+ :class="[
+ 'w-full flex items-center justify-between px-3 py-2.5 rounded-lg border transition-all duration-200',
+ incognitoMode
+ ? 'bg-gradient-to-r from-violet-500/10 to-purple-500/10 border-violet-400/50 dark:border-violet-500/50'
+ : 'bg-[var(--bg-tertiary)] border-[var(--border-secondary)] hover:border-[var(--border-focus)]'
+ ]">
+ <div class="flex items-center gap-3">
+ <div :class="[
+ 'w-8 h-8 rounded-full flex items-center justify-center transition-all',
+ incognitoMode
+ ? 'bg-gradient-to-br from-violet-500 to-purple-600 text-white'
+ : 'bg-[var(--bg-secondary)] text-[var(--text-muted)]'
+ ]">
+ <i class="fas fa-user-secret text-sm"></i>
+ </div>
+ <div class="text-left">
+ <span :class="['text-sm font-medium', incognitoMode ? 'text-violet-700 dark:text-violet-300' : 'text-[var(--text-secondary)]']">
+ Incognito Mode
+ </span>
+ <p v-if="!incognitoMode" class="text-[10px] text-[var(--text-muted)]">
+ Process without saving
+ </p>
+ <p v-else class="text-[10px] text-violet-600 dark:text-violet-400">
+ Session only &bull; Not saved to account
+ </p>
+ </div>
+ </div>
+ <div :class="[
+ 'w-10 h-5 rounded-full relative transition-all duration-200',
+ incognitoMode ? 'bg-gradient-to-r from-violet-500 to-purple-500' : 'bg-[var(--bg-secondary)]'
+ ]">
+ <div :class="[
+ 'absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-all duration-200',
+ incognitoMode ? 'left-5' : 'left-0.5'
+ ]"></div>
+ </div>
+ </button>
+ </div>
+
<!-- Upload/Discard Buttons -->
<div class="flex flex-col sm:flex-row gap-3 justify-center">
- <button @click="uploadRecordedAudio"
- class="flex-1 px-6 py-3 bg-[var(--bg-button)] text-[var(--text-button)] rounded-lg hover:bg-[var(--bg-button-hover)] transition-colors flex items-center justify-center gap-2">
- <i class="fas fa-upload"></i>
- <span v-text="t('help.uploadRecordingNotes')"></span>
- </button>
+ <!-- Normal Upload Button -->
+ <button v-if="!incognitoMode || !enableIncognitoMode"
+ @click="uploadRecordedAudio"
+ class="flex-1 px-6 py-3 bg-[var(--bg-button)] text-[var(--text-button)] rounded-lg hover:bg-[var(--bg-button-hover)] transition-colors flex items-center justify-center gap-2">
+ <i class="fas fa-upload"></i>
+ <span v-text="t('help.uploadRecordingNotes')"></span>
+ </button>
+ <!-- Incognito Upload Button -->
+ <button v-else
+ @click="uploadRecordedAudioIncognito"
+ :disabled="incognitoProcessing"
+ class="flex-1 px-6 py-3 bg-gradient-to-r from-violet-500 to-purple-600 text-white rounded-lg hover:from-violet-600 hover:to-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-all flex items-center justify-center gap-2 shadow-sm">
+ <i :class="incognitoProcessing ? 'fas fa-spinner fa-spin' : 'fas fa-user-secret'"></i>
+ <span v-if="incognitoProcessing">Processing...</span>
+ <span v-else>Process in Incognito</span>
+ </button>
<button @click="discardRecording"
class="px-6 py-3 bg-[var(--bg-danger)] text-white rounded-lg hover:bg-[var(--bg-danger-hover)] transition-colors flex items-center justify-center gap-2">
<i class="fas fa-trash"></i>