Instreamatic offers consumers the power of a voice command while listening to a digital radio stream. Users can say 'Hey, Radio' and ask to open a webpage, show directions, request a promo code, and more. The ad will deliver an appropriate target action.
To fully enable the App, microphone access permission needs to be activated to your App manifest. You can learn more about how to do this via the following link:
Please note that the application must be developed as a foreground service.
And the foreground service must be launched while the activity is visible.
Microphone access must be declared for foreground service as well.
Please see the link below for reference:
For an actual example of foreground service, please click HERE
(Please turn off the AdBlocker to access the repository)
Project Configuration
repositories {jcenter()mavenCentral() maven { url 'http://instreamatic.com/nexus/repository/maven-public'}}ext { admanVersion ='9.2.2' serVersion ='6.15.0' admanEmbdVersion ='1.1.1' admanUWphraseVersion ='1.0.0'}dependencies { api 'com.instreamatic:adman-android:'+project.ext.admanVersion+'@aar' api 'com.instreamatic:adman-android-view:'+project.ext.admanVersion+'@aar' api 'com.instreamatic:adman-android-voice:'+project.ext.admanVersion+'@aar' api 'com.sensory.speech.snsr:tnl:'+project.ext.serVersion+'@aar' api 'com.instreamatic.embedded:phrase-spot:'+project.ext.admanEmbdVersion+'@aar' api 'com.instreamatic.embedded:voice-recognition-embedded:'+project.ext.admanEmbdVersion+'@aar' api 'com.instreamatic:adman-android-module-wphrase:'+project.ext.admanUWphraseVersion+'@aar'}android {... packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/notice.txt' exclude 'META-INF/license.txt' exclude 'META-INF/dependencies.txt' exclude 'META-INF/LGPL2.1'}}
Implementation
Create an instance of Adman first
Then, set up ad request parameters. You can use the same SDK installation for both Voice Ads and Active Audio.
Voice Ads parameters example
Active Audio parameters example
If you need to switch between Voice Ads and Active Audio ads, add the following when updating the request parameters
Usage example:
This approach to Active Audio must be used when you are going to play the ad with Instreamatic SDK. If you are going to play it with your own player or insert it into a stream, please see below for detailed instructions.
You can use the default approach for Voice Ads though.
If you want to add more models for on-device recognition, add one more VoiceRecognitionEmbedded::addModel with another model.
Ad Request and Playback
This approach to Active Audio must be used when you are going to play the ad with Instreamatic SDK. If you are going to play it with your own player or insert it into a stream, please see below for detailed instructions.
You can use the default approach for Voice Ads though.
Ad Request and Playback for Voice Ads:
This is just a single use-case. You can request an ad at another event, but please keep the above sequence unchanged.
Ad Request and Playback for Active Audio:
If your request parameters were set for Active Audio, the above method will request an ad and then play it right away.
Instreamatic VOR Ad can be identified by the following values in the VAST Document:
“instreamatic” in the <AdSystem> tag;
“![CDATA[ vor ]]” in the “Type” extension
The combination of the two values above indicates the VOR Ad.
The Audio Ad can be found in the <MediaFiles> section of the VAST Document. This is the part for in-stream insertion.
Example:
It’s possible to get audio files in different codecs: MP3 192kbps/128kbps, AAC 32kbps/64kbps, m4a 32kbps/64kbps.
Before playing an ad, the XML response must be converted to an array of bytes.
At the ad placement with Active Audio, call the following method:
Instreamatic SDK will start listening to the wake-word and you'll receive the START_DETECT event.
The SDK will wait for the wake-word while the ad is playing. You can retrieve the ad duration using the below method (if needed):
If SDK will catch the wake-word, it will enable the mic for command recognition. STOP_DETECT event will be reported.
Then the SDK will send the START event from AdmanVoice-module. This event must be used as an indication of the moment when the stream volume must be lowered.
At the end of the recognition session, the SDK will send the STOP event. This event must be used as an indication of the moment when the stream volume must be turned back on.
Don’t forget to call adman.sendCanShow() on all the ad placements even if there is no ad to play.
//App is started.
//You are preloading ad at the start of the session
//After the init of the SDK you are preloading an ad:
adman.preload();
//wait for an ad placement.
//For example it's a pre-roll and 'play' button is pressed:
adman.sendCanShow();
//Here you will need to check if there is an ad available for playback
//If the state of Adman is AdmanEvent.Type.READY then ad must be played
adman.play();
//if there is no ad available, return listener to a content and try requesting another ad