/* Copyright 2026 Marimo. All rights reserved. */ import type { JSX } from "react"; import { z } from "zod"; import { AudioRecorder } from "@/components/audio/audio-recorder"; import { useAudioRecorder } from "@/hooks/useAudioRecorder"; import type { IPlugin, IPluginProps } from "@/plugins/types"; import { blobToString } from "@/utils/fileToBase64"; import { Labeled } from "./common/labeled"; /** * Base64 encoded audio file. */ type Value = string; interface Data { label?: string | null; } export class MicrophonePlugin implements IPlugin { tagName = "marimo-microphone"; validator = z.object({ label: z.string().nullish(), }); render(props: IPluginProps): JSX.Element { return ; } } const Microphone = ({ setValue, data }: IPluginProps) => { const { start, stop, pauseResume, recordingStatus, recordingTime, allowed } = useAudioRecorder({ onDone: async (file) => { const base64 = await blobToString(file, "base64"); setValue(base64); }, }); return ( {!allowed && (
Microphone access is disabled. Please allow microphone access in your browser.
)}
); };