Api Reference

API reference

Client exports

NewAction(actionTable)

Add a voice command at runtime.

local id = exports['stratis-voice']:NewAction({
    phrases = { 'panic button' },
    actionType = 'event',
    eventType = 'client',
    eventName = 'my-script:panic',
    minimumConfidence = 0.5
})

Returns the runtime action ID, or nil plus error message on failure.

Runtime actions cannot use eventType = 'server'.

RemoveAction(runtimeId)

Remove a runtime action.

exports['stratis-voice']:RemoveAction(id)

Returns true on success, false if the ID doesn't exist.

SetLanguage(languageCode)

Change the transcription language at runtime.

exports['stratis-voice']:SetLanguage('es')

Returns true if accepted.

Server exports

IsSpeechApproved(playerSource)

Check if a player has approved microphone access.

if exports['stratis-voice']:IsSpeechApproved(source) then
    -- player has mic enabled
end

Events

Client

  • stratis-voice:client:openApprovalMenu - trigger to open the approval popup
  • stratis-voice:client:transcribed - fired with the transcription result. Payload: { success, text, confidence, error, elapsedMs }

Server

  • stratis-voice:server:setApproval - sent by client when approval state changes
  • stratis-voice:server:executeAction(actionId, sentence, confidence) - fires when a configured server action matches
  • stratis-voice:server:blacklistHit(word, sentence, confidence) - fires when a blacklisted word is detected

Configured server actions

For an action with actionType = 'event', eventType = 'server', the server event fires with this signature:

AddEventHandler('your:server:event', function(playerSource, payload)
    -- payload.source       (number)  player ID
    -- payload.sentence     (string)  normalized recognized text
    -- payload.confidence   (number)  0.0 to 1.0
    -- payload.arguments    (table)   from action.arguments
    -- payload.actionId     (number)  index in Config.Actions
end)

Console commands

Server console

  • stratisvoice_quota - print today's transcription count per player

In-game

  • /voice - toggle voice mode (same as F7)
  • /voiceapproval - re-show the microphone permission popup
  • /voicemic - open the microphone picker
  • /speechdiag - print the client state machine status to console
  • /speechstatus - notification with current state

View Rivo Voice