export function transcript(data){ if(!Array.isArray(data?.content)||!data.content.every(s=>s&&typeof s.text==='string'))throw Error('The speech service did not return a valid transcript. No text was invented.'); const text=data.content.map(s=>s.text.trim()).filter(Boolean).join(' ').trim(); if(!text)throw Error('No spoken text was returned. No transcript was created.'); return {text,language:data.lang||'unknown',word_count_whitespace:text.split(/\s+/).length}; }