API
How to guides
Override Microphone + Language Detection Template Guide
22min
this example template enables users to speak with a unith digital human using a microphone button it is intended for developers who would like to create a create a bespoke microphone experience it includes voice activity detection (vad) azure speech sdk automatic language detection transcript preview message delivery via postmessage assumes the digital human is configured to accept external events as defined here ๐ฆ features feature description ๐๏ธ click to activate mic manual start/stop mic via button ๐ง voice activity detection only triggers when real speech is detected ๐ language detection auto detects up to 4 supported languages ๐งพ live transcript displays recognized speech as text ๐ค sends message to dh final transcript sent to unith iframe ๐ how it works 1\ embed unith iframe use mode=video if you would like to hide the unith chat widget and only leverage the video component unsert the appropriate api key for your org must include allow="microphone" for more information on video only mode, see this page 2\ azure speech key configuration step 1 get your credentials log in to azure portal https //portal azure com/ create a speech resource (cognitive services) copy your key region step 2 add to template replace these lines in your template (below) const speechkey = "your azure speech key"; const serviceregion = "your azure region"; // e g "eastus" do not expose real keys in production environments 3\ auto language detection configure your supported languages const autodetectsourcelanguageconfig = speechsdk autodetectsourcelanguageconfig fromlanguages(\[ "en us", "fr fr", "es es" ]); โ
limit azure allows max 4 languages for auto detect 4\ transcript display (optional) live updates as you speak transcriptel innertext = "transcript " + transcriptbuffer; 5\ message delivery after recognition ends, this is called iframe contentwindow\ postmessage({ event "dh message", payload { message finalmessage } }, "https //chat unith ai"); configure the digital human to accept external events as defined here this can also be done directly via the advanced modification window in interface ๐งช silence handling after 2 seconds of silence, the recognizer will stop function resetsilencetimer() { silencetimer = settimeout(() => { status innertext = "status silence detected stopping recognition "; recognizer stopcontinuousrecognitionasync(); }, 2000); } modify this if you want always on behavior ๐ customization options task how ๐ change languages edit the fromlanguages array ๐ฏ change unith digital human modify iframe src ๐จ customize ui change button or layout ๐ disable silence timeout remove resetsilencetimer() logic โ
setup checklist task complete? embed iframe with correct url โฌ add azure speechkey and region โฌ configure languages โฌ replace placeholder vad js โฌ test in browser โฌ template & examples files example template html vad js example template unith mic + language detection ๐ง activate mic status waiting transcript vad js // minimal vad mock for offline testing (replace with actual implementation if needed) function vad(stream, options) { console warn("โ ๏ธ vad mock triggered replace with real vad js "); if (options && typeof options onvoicestart === 'function') { settimeout(() => { options onvoicestart(); // simulate voice start after delay }, 1000); } }