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 streaming model, create a session, and let the SDK capture microphone audio:
import { loadSttModel } from "@wfloat/wfloat-web";
const stt = await loadSttModel("k2-fsa/streaming-zipformer-en");
const session = await stt.createSession();
await session.startMicrophone({
sampleRate: 16000,
onResult(partial) {
console.log(partial.text, partial.isEndpoint);
},
});
// Call these when the user stops recording.
await session.stopMicrophone();
const result = await session.finish();
console.log(result.text);
await session.close();
For an application-owned audio pipeline, use session.push({ audio, sampleRate }) and read partial results with session.getResult().
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 open a streaming session:
import { loadSttModel } from '@wfloat/react-native-wfloat';
const stt = await loadSttModel('k2-fsa/streaming-zipformer-en');
const session = await stt.createSession();
await session.startMicrophone({
sampleRate: 16000,
onResult(partial) {
console.log(partial.text, partial.isEndpoint);
},
});
// Call these when the user stops recording.
await session.stopMicrophone();
const result = await session.finish();
console.log(result.text);
await session.close();
For application-owned PCM audio, feed chunks with session.push({ audio, sampleRate }).
Install the Python SDK:
pip install wfloat
Load the model and create a streaming session:
import wfloat
stt = wfloat.load_stt_model("k2-fsa/streaming-zipformer-en")
session = stt.create_session()
try:
# pcm_chunk is a sequence of mono floating-point samples.
session.push(pcm_chunk, sample_rate=16000)
partial = session.get_result()
print(partial.text)
final_result = session.finish()
print(final_result.text)
finally:
session.close()
Call session.push(...) repeatedly as audio arrives, rather than waiting for the complete recording.