Examples
WebSocket protocol
The following diagram explains the interaction between a client and Rev AI for a WebSocket protocol connection:
Here is an example of the messages between a client and Rev AI during a single WebSocket streaming session.
Client --> Rev AI
GET /speechtotext/v1/stream?access_token=REVAI_ACCESS_TOKEN&content_type=audio/x-raw;layout=interleaved;rate=16000;format=S16LE;channels=1&language=en HTTP/1.1
Host: api.rev.ai
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: Chxzu/uTUCmjkFH9d/8NTg==
Sec-WebSocket-Version: 13
Origin: http://api.rev.ai
Client <-- Rev AI
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: z0pcAwXZZRVlMcca8lmHCPzvrKU=
Client <-- Rev AI
{
"type": "connected",
"id": "s1d24ax2fd21"
}
Client --> Rev AI
[binary audio data]
Client <-- Rev AI
{
"type": "partial",
"ts": 1.01,
"end_ts": 1.55,
"elements": [
{
"type": "text",
"value": "one"
}
],
}
Client <-- Rev AI
{
"type": "partial",
"ts": 1.01,
"end_ts": 2.2,
"elements": [
{
"type": "text",
"value": "one"
},
{
"type": "text",
"value": "tooth"
}
],
}
Client --> Rev AI
[binary audio data]
Client <-- Rev AI
{
"type": "partial",
"ts": 1.01,
"end_ts": 3.2,
"elements": [
{
"type": "text",
"value": "one"
},
{
"type": "text",
"value": "tooth"
},
{
"type": "text",
"value": "three"
}
],
}
Client <-- Rev AI
{
"type": "final",
"ts": 1.01,
"end_ts": 3.2,
"elements": [
{
"type": "text",
"value": "One",
"ts": 1.04,
"end_ts": 1.55,
"confidence": 1.0
},
{
"type": "punct",
"value": " "
},
{
"type": "text",
"value": "two",
"ts": 1.84,
"end_ts": 2.15,
"confidence": 1.0
},
{
"type": "punct",
"value": "."
}
]
}
Client --> Rev AI
[binary audio data]
Client <-- Rev AI
{
"type": "partial",
"ts": 3.56,
"end_ts": 6.43,
"elements": [
{
"type": "text",
"value": "five"
},
{
"type": "text",
"value": "sticks"
}
],
}
Client <-- Rev AI
{
"type": "partial",
"ts": 3.56,
"end_ts": 7.03,
"elements": [
{
"type": "text",
"value": "five"
},
{
"type": "text",
"value": "six"
}
],
}
Client --> Rev AI
[binary audio data]
Client --> Rev AI
[text] EOS
Client <-- Rev AI
{
"type": "final",
"ts": 3.56,
"end_ts": 7.03,
"elements": [
{
"type": "text",
"value": "Five",
"ts": 4.04,
"end_ts": 4.45,
"confidence": 1.0
},
{
"type": "punct",
"value": " ",
},
{
"type": "text",
"value": "six",
"ts": 5.14,
"end_ts": 6.23,
"confidence": 1.0
},
{
"type": "punct",
"value": ".",
}
]
}
RTMP streaming
The following diagram explains the interaction between a client and Rev AI for an RTMP streaming session: