Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
Android Guides
Playing Audio Indications

Playing Audio Indications

As of library v.4.7 and SDL Core v.5.0+, you can pass an uploaded audio file's name to TTSChunk, allowing any API that takes a text-to-speech parameter to pass and play your audio file. A sports app, for example, could play a distinctive audio chime to notify the user of a score update alongside an Alert request.

Uploading the Audio File

The first step is to make sure the audio file is available on the remote system. To upload the file use the FileManager.

SdlFile audioFile = new SdlFile("Audio file name", FileType.AUDIO_MP3, Uri.parse("File Location"), true);
sdlManager.getFileManager().uploadFile(audioFile, new CompletionListener() {
    @Override
    public void onComplete(boolean success) {

    }
});

For more information about uploading files, see the Uploading Files guide.

Using the Audio File

Now that the file is uploaded to the remote system, it can be used in various RPCs, such as Speak, Alert, and AlertManeuver. To use the audio file in an alert, you simply need to construct a TTSChunk referring to the file's name.

Alert alert = new Alert();
alert.setAlertText1("Alert Text 1");
alert.setAlertText2("Alert Text 2");
alert.setDuration(5000);
alert.setTtsChunks(Arrays.asList(new TTSChunk("Audio file name", SpeechCapabilities.FILE)));
View on GitHub.com
Previous Section Next Section