Capítulo 749 de 988
:::warning Unstable API: This package is experimental for the moment. As we test it, we might make a few changes to the API and switch to a WebGPU-based backend in the future.
export default function MyComponent() {
const [supported, setSupported] = useState<boolean | null>(null);
const [reason, setReason] = useState<string | undefined>(undefined);
useEffect(() => {
const checkSupport = async () => {
const modelToUse: WhisperWebModel = 'tiny.en'; // Or any other model
const result = await canUseWhisperWeb(modelToUse);
setSupported(result.supported);
if (!result.supported) {
setReason(result.detailedReason ?? result.reason);
}
};
checkSupport();
}, []);
if (supported === null) {
return <p>Checking if Whisper Web can be used...</p>;
}
if (supported) {
return <p>Can use Whisper Web!</p>;
}
return <p>Using Whisper Web is not possible: {reason}</p>;
}