Best Practices for Audio
Stay organized with collections
Save and categorize content based on your preferences.
This page contains recommendations on how to provide speech data to the
Google Assistant API. These guidelines are designed for greater efficiency
and accuracy as well as reasonable response times from the service.
Audio pre-processing
It's best to provide audio that is as clean as possible by using a good quality
and well-positioned microphone. However, applying noise-reduction signal
processing to the audio before sending it to the service typically reduces
recognition accuracy. The service is designed to handle noisy audio.
For best results:
- Position the microphone as close to the user as possible, particularly when
background noise is present.
- Avoid audio clipping.
- Do not use automatic gain control (AGC).
- All noise reduction processing should be disabled.
Ideally:
- The audio level should be calibrated so that the input signal does not clip,
and peak speech audio levels reach approximately -20 to -10 dBFS.
- The device should exhibit approximately "flat" amplitude versus
frequency characteristics (+- 3 dB 100 Hz to 8000 Hz).
- Total harmonic distortion should be less than 1% from 100 Hz to 8000
Hz at 90 dB SPL input level.
Sampling rate
If possible, set the sampling rate of the audio source to 16000 Hz. Otherwise,
set the sample_rate_hertz
to match the native sample rate of the audio source (instead
of re-sampling).
Frame size
The Google Assistant recognizes live audio as it is captured from a microphone.
The audio stream must be split into frames and sent in consecutive
AssistRequest
messages. Any frame size is acceptable. Larger frames are more
efficient, but add latency. A 100-millisecond frame size is recommended as a
good tradeoff between latency and efficiency.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThis page provides recommendations for submitting speech data to the Google Assistant API for optimal performance.\u003c/p\u003e\n"],["\u003cp\u003eFor best results, use a high-quality microphone, position it close to the user, avoid audio clipping and noise reduction processing, and disable automatic gain control.\u003c/p\u003e\n"],["\u003cp\u003eIdeally, calibrate audio levels to prevent clipping, maintain a flat frequency response, and minimize harmonic distortion.\u003c/p\u003e\n"],["\u003cp\u003eSet the audio source sampling rate to 16000 Hz if possible, or match the native rate, and use a frame size of around 100 milliseconds for a balance between latency and efficiency.\u003c/p\u003e\n"]]],[],null,["# Best Practices for Audio\n\nThis page contains recommendations on how to provide speech data to the\nGoogle Assistant API. These guidelines are designed for greater efficiency\nand accuracy as well as reasonable response times from the service.\n\nAudio pre-processing\n--------------------\n\nIt's best to provide audio that is as clean as possible by using a good quality\nand well-positioned microphone. However, applying noise-reduction signal\nprocessing to the audio before sending it to the service typically reduces\nrecognition accuracy. The service is designed to handle noisy audio.\n\nFor best results:\n\n- Position the microphone as close to the user as possible, particularly when background noise is present.\n- Avoid audio clipping.\n- Do not use automatic gain control (AGC).\n- All noise reduction processing should be disabled.\n\nIdeally:\n\n- The audio level should be calibrated so that the input signal does not clip, and peak speech audio levels reach approximately -20 to -10 dBFS.\n- The device should exhibit approximately \"flat\" amplitude versus frequency characteristics (+- 3 dB 100 Hz to 8000 Hz).\n- Total harmonic distortion should be less than 1% from 100 Hz to 8000 Hz at 90 dB SPL input level.\n\nSampling rate\n-------------\n\nIf possible, set the sampling rate of the audio source to 16000 Hz. Otherwise,\nset the [`sample_rate_hertz`](/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#google.assistant.embedded.v1alpha2.AudioInConfig) to match the native sample rate of the audio source (instead\nof re-sampling).\n\nFrame size\n----------\n\nThe Google Assistant recognizes live audio as it is captured from a microphone.\nThe audio stream must be split into frames and sent in consecutive\n`AssistRequest` messages. Any frame size is acceptable. Larger frames are more\nefficient, but add latency. A 100-millisecond frame size is recommended as a\ngood tradeoff between latency and efficiency."]]