Chat
Audio
Process and analyze audio inputs with chat models.
Chat + Audio (Audio as Input
)
The Bytez API allows chat models to process audio files
alongside text, enabling tasks like transcription, voice command recognition, and conversational AI with spoken inputs.
Use chat models to analyze audio files, transcribe speech, or respond to sound-based queries. Below are examples using both the REST API and JavaScript SDK.
Code
Text + Audio
This example sends an audio file along with a text prompt for analysis.
Streaming
Streaming allows you to receive model outputs incrementally as soon as they are available, which is ideal for tasks like real-time responses or large outputs.
How Streaming Works
To enable streaming, pass true
as the third argument to the model.run()
function. The model will return a stream that you can read incrementally.
javascript
Node.js Example
javascript
Browser Example
javascript
Key Points
Node.js
: Convert the Web Stream usingReadable.fromWeb()
for compatibility.Browser
: UsegetReader()
andTextDecoder
to process the stream.Error Handling
: Both methods use try…catch to handle potential errors.Data Handling
: Data chunks are processed as they arrive via data events or.read()
calls.
Explore Specialized Models
You might also be interested in pretrained models for tasks like:
Speech-to-Text
: Convert spoken words into written text.Audio Classification
: Categorize audio files into predefined labels.