constMessage=UiSchema.TaggedEnum({SpokeVoice:{audio:Schema.instanceOf(Blob),seconds:Schema.Number},FinishedVoice:{audio:Schema.instanceOf(Blob),seconds:Schema.Number},CancelledVoice:{},})// transcribe `Spoke` for the live preview (pass it back as `transcript`), and `Finished` to sendexportconstDictation=(h:Html.H<typeofMessage.Type>,heard: string)=>VoiceInput(h,{props:{transcript: heard },onEmit:{Started:()=>undefined,Spoke:({ audio, seconds })=>Message.SpokeVoice({ audio, seconds }),Finished:({ audio, seconds })=>Message.FinishedVoice({ audio, seconds }),Cancelled:()=>Message.CancelledVoice(),},})
API reference
Props
VoiceInput props
Name
Type
Description
transcript
string
What the app has heard so far, from Spoke; shown while listening
disabled
boolean
The mic can't be used right now (a reply is streaming, no plan)
Events
VoiceInput events
Event
Payload
Description
Started
{}
The microphone is on
Spoke
{ audio: instanceOf; seconds: number }
The audio so far, about once a second, for a live transcript
Finished
{ audio: instanceOf; seconds: number }
The person sent the recording: transcribe it and send the text