# Voice activation optimization

Many Bluetooth headsets support the Bluetooth Voice Recognition Activation
(BVRA) command. Google Assistant, via the Google Assistant app running on a
paired mobile device, uses BVRA to initiate a Google Voice Assistant (GVA)
session. Optimizing the transmission for BVRA reduces latency in the signal
chain.

## Analyzing latency in the command chain

During typical usage, the link between a Bluetooth headset and its audio gateway
(for example, a paired mobile device) operates in sniff mode. The typical sniff
parameters are set to 500 ms.

Some headsets leave the link in sniff mode and send the BVRA command in the
following manner:

| Time since sniff | Description |
|---|---|
| 0 ms | Headset sends `AT + BVRA = 1` command to audio gateway. `AT` references AT commands that are sent over HFP (hands-free protocol). |
| 500 ms | Audio gateway takes the link out of sniff mode |
| 501 ms | Audio gateway sends BVRA `OK` |
| 502 ms | Audio gateway opens a Synchronous Connection-Oriented (SCO) link with the headset |
| ... |   |

If the headset brings the link out of sniff mode before the BVRA command is
sent, then the following flow occurs:

| Time since out of sniff | Description |
|---|---|
| 0 ms | Headset takes the link out of sniff mode |
| 1 ms | Headset sends `AT + BVRA = 1` command to audio gateway |
| 2 ms | Audio gateway sends BVRA `OK` |
| 3 ms | Audio gateway opens SCO |
| ... |   |

From the analysis, taking the link out of sniff mode before the BVRA command is
sent saves 500 ms (or the sniff time interval).

## Recommendations

Before the audio gateway sends a BVRA command, ensure the link is awake first.
This improvement can reduce BVRA-associated latency by one sniff interval.

Additionally, there might be other commands that could benefit from taking the
link out of sniff mode first. You should survey your implementation to assess
potential savings.

### Version history

| Date | Description |
|---|---|
| 2020-07-13 | Added initial version of page |