SpeechTilesAndamento Docs
Get started
Guide

STMediaRunner API Reference

STMediaRunner.shared provides access to the shared media runtime in SpeechTiles Andamento. It lets applications play audio, synthesize speech, record audio, and recognize speech through a unified Swift API.

What is STMediaRunner?

STMediaRunner is the media engine for applications that need to play audio, generate speech, record sound, or recognize spoken words. It provides one consistent Swift API for these operations and reports results through media events.

What can it do?

  • Play audio and speak text: Play recorded audio files or synthesize speech, with playback controls for volume, speed, pause, resume, and stop.
  • Record audio: Capture microphone input or work with audio files.
  • Recognize speech: Convert spoken audio into recognition results using an initialized speech recognition engine.
  • Manage audio: Configure audio routing, background audio behavior, and standard or conversational audio processing.
  • Report events: Receive notifications when an operation starts, progresses, finishes, or fails.

How do I use it?

Access STMediaRunner.shared, call initialize(), and initialize the media components your app needs—for example, initializeAudioPlayer() before playback. Request the required microphone or speech-recognition permissions before using those features.

Call a media method such as playAudio(...) to start work. A successful STResult means the request was accepted; listen for media events to learn when the operation actually finishes.

For a complete, managed voice conversation, use STConversationRunner, which coordinates these media services for you.

Lifecycle

Logging

  • setLogLevel

    setLogLevel(_ level: STLogLevel)

  • setLogLevels

    setLogLevels(_ levels: [STMediaComponent: STLogLevel])

  • logLevel

    logLevel(for component: STMediaComponent) -> STLogLevel?

Audio Environment

  • configureAudioEnvironment

    configureAudioEnvironment( mode: STAudioEnvironmentMode = .default, options: STAudioEnvironmentOptions = [] ) -> STResult

  • setAudioOutput

    setAudioOutput(_ output: STAudioOutput) -> STResult

  • setAudioProcessingMode

    setAudioProcessingMode( _ mode: STAudioProcessingMode, completion: ((STResult) -> Void)? = nil )

Permissions

Playback

Speech Synthesis

Recording

Speech Recognition

  • getSREngineState

    getSREngineState() -> STSREngineState

  • getSelectedSREngine

    getSelectedSREngine() -> String?

  • getSelectedSRLanguageCode

    getSelectedSRLanguageCode(_ srEngine:String? = nil) -> String

  • initializeSREngine

    initializeSREngine(srEngine:String? = nil, languageCode:String? = nil) -> STResult

  • releaseSREngine

    releaseSREngine() -> STResult

  • requestSpeechRecognitionPermission

    requestSpeechRecognitionPermission() -> STResult

  • loadContextualPhrases (Array)

    loadContextualPhrases(_ contextualPhrases: [String: String]) -> STResult

  • recognizeDeviceAudio

    recognizeDeviceAudio(_ mediaJobID:String, srTaskID:String, srParams:STSRParams? = nil, audioRecordParams:STAudioRecordParams? = nil, recordUtteranceAudio:Bool = false) -> STResult

  • recognizeFileAudio

    recognizeFileAudio(_ mediaJobID:String, srTaskID:String, sourceURL: URL, srParams:STSRParams? = nil, audioRecordParams:STAudioRecordParams? = nil, recordUtteranceAudio:Bool = false) -> STResult

  • recognizeFileAudioDirect

    recognizeFileAudioDirect(_ mediaJobID:String, srTaskID:String, sourceURL: URL, srParams:STSRParams? = nil) -> STResult

  • stopRecognizeAudio

    stopRecognizeAudio(_ mode: STSpeechRecognitionStopMode = .finish) -> STResult