We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Speech-to-text
Install the browser SDK:
npm install @wfloat/wfloat-web
Load the model and pass a browser File, Blob, ArrayBuffer, or decoded audio buffer to transcribe:
import { loadSttModel } from "@wfloat/wfloat-web";
const stt = await loadSttModel("openai/whisper-tiny-en", {
language: "en",
onProgress(event) {
console.log(event.status);
},
});
const file = document.querySelector<HTMLInputElement>("#audio-file")?.files?.[0];
if (!file) throw new Error("Choose an audio file first.");
const result = await stt.transcribe({ audio: file });
console.log(result.text);
For microphone input, call await stt.startMicrophone(), then pass the value returned by await stt.stopMicrophone() to stt.transcribe(...).
Install the React Native SDK:
npm install @wfloat/react-native-wfloat
Run pod install from the app’s ios directory, and configure microphone permission for the target platform. Then record and transcribe locally:
import { loadSttModel } from '@wfloat/react-native-wfloat';
const stt = await loadSttModel('openai/whisper-tiny-en', {
language: 'en',
});
await stt.startMicrophone({ sampleRate: 16000 });
// Call this when the user stops recording.
const recording = await stt.stopMicrophone();
const result = await stt.transcribe(recording);
console.log(result.text);
You can also call transcribe({ audio, sampleRate }) with mono PCM samples that your application already owns.
Install the Python SDK:
pip install wfloat
Load the model and transcribe a mono 16-bit PCM WAV file:
import wfloat
stt = wfloat.load_stt_model(
"openai/whisper-tiny-en",
language="en",
)
result = stt.transcribe(audio="recording.wav")
print(result.text)
For in-memory audio, pass a sequence of floating-point mono samples and provide its sample_rate.