create Streaming Session
suspend fun createStreamingSession(catalog: Catalog, audioSampleRateInHz: AudioSampleRateInHz, audioRecordReadBufferSize: Int): ShazamKitResult<ShazamKitException, StreamingSession>
Content copied to clipboard
Creates a StreamingSession that allows matching a stream of audio in realtime. The audio format must be PCM 16bit MONO in one of the following sample rates:
48000 Hz
44100 Hz
32000 Hz
16000 Hz
Example usage:
viewModelScope.launch {
when (val result = ShazamKit.createStreamingSession(
shazamCatalog,
sampleRate,
readBufferSize
)) {
is Success -> {
val session = result.data
session.match(signature)
}
is Failure -> error("Error: ${result.reason}")
}
}
This is safe to call on Main dispatcher.
Return
A ShazamKitResult object containing either the SignatureGenerator or an ShazamKitException if an error occurred.
Parameters
catalog
The Catalog that is used to match the signature. See createShazamCatalog to obtain a catalog that matches the provided audio with the Shazam Service.
audioSampleRateInHz
The audio sample rate in Hz. Supported sample rates are defined as values of the enum AudioSampleRateInHz.
audioRecordReadBufferSize
The size of the buffer used to provide the chunks of audio.