Learn how to setup voice search with Trieve
Trieve provides a simple way to integrate voice search into your application. This guide will walk you through the steps to set up voice search with Trieve.
For a full implementation example, take a look at the way we implement voice search in our search component.
To enable voice search, you’ll need to capture audio from the user’s microphone using the browser’s MediaRecorder
API.
The following React component lets users start and stop voice recording:
To send the recorded audio to Trieve, convert the audio blob into a base64 string.
Once the audio is recorded and converted to base64, send it to Trieve. The platform will transcribe the speech using OpenAI Whisper and return the search results based on the transcription.
We return the transcribed text in the response header as x-tr-query
, which can be used to update the UI with the search query.
Different browsers support different audio formats. Handle this by selecting the correct MIME type: