/// import { Cell, computed, type Default, NAME, recipe, UI } from "commontools"; // Type definition for transcription data (from ct-voice-input component) interface TranscriptionChunk { timestamp: [number, number]; text: string; } interface TranscriptionData { id: string; text: string; chunks?: TranscriptionChunk[]; audioData?: string; duration: number; timestamp: number; } type Input = { title?: Cell>; }; type Output = { transcription: Default; }; const VoiceNoteSimple = recipe( "Voice Note Simple", ({ title }) => { const transcription = Cell.of(null); const hasTranscription = computed(() => transcription.get() !== null); const transcriptionText = computed(() => transcription.get()?.text || ""); const transcriptionDuration = computed( () => transcription.get()?.duration || 0, ); const transcriptionTimestamp = computed( () => transcription.get()?.timestamp || Date.now(), ); return { [NAME]: title, [UI]: ( Voice Input Component Test Hold the microphone button to record. Release to transcribe. {hasTranscription && ( Latest Transcription {transcriptionText} Duration: {transcriptionDuration.toFixed(1)}s Recorded:{" "} {new Date(transcriptionTimestamp).toLocaleTimeString()} )} ), transcription, }; }, ); export default VoiceNoteSimple;
Hold the microphone button to record. Release to transcribe.
{transcriptionText}