Transcribe pre-segmented speech
This event can be used to transcribe pre-segmented speech and should provide the following payload:
- audio samples serialized as bytes
- audio sample type string (one of ‘int16’, ‘int32’, ‘float32’, ‘float64’)
const response = await fetch('test_audio.wav')
const blob = await response.blob()
const arrayBuffer = await blob.arrayBuffer()
const audioData = new Int16Array(arrayBuffer)
socketLocal.emit('recognize_audio_samples', audioData, 'int16')
The server will respond by immediately emitting a request_received event with the following payload:
{
request_id: str
}
When request processing is completed, the server will emit a recognition event with the following payload:
{
text: str
request_id: str
}
The text value may be null if the processed segment didn’t contain any speech, or if request processing failed.
The event may be captured as follows:
socketLocal.on('recognition', (data) => {
console.log('recognition', data.text, new Date())
}