Language Model Action Set

End-to-End Speech to Text with Speaker Identification Using the transcribeSpeech Action

This example is not available for the CAS programming language.

End-to-End Speech to Text with Speaker Identification Using the transcribeSpeech Action

This example is not available for the Lua programming language.

End-to-End Speech to Text with Speaker Identification Using the transcribeSpeech Action

This section contains Python code. For more information about coding in Python, see Getting Started with SAS Viya for Python and SAS Viya: System Programming Guide.

The following code shows how you can use the transcribeSpeech action for end-to-end speech recognition together with speaker identification in CAS:

# load the audio and langModel action sets
s.loadactionset(actionset='audio')
s.loadactionset(actionset='langModel')

# load the audio input
s.audio.loadaudio(
   caslib = 'speech_data',
   casout = {'name':'sample_input','replace':True},
   path   = 'sample.listing'
)

# load the acoustic model, weights, and weights attributes
s.table.loadtable(
   caslib = 'speech_model',
   casout = {'name':'asr','replace':True},
   path   = 'acoustic_model_cpu.sashdat'
)
s.table.loadtable(
   caslib = 'speech_model',
   casout = {'name':'pretrained_weights','replace':True},
   path   = 'acoustic_model_cpu_weights.sashdat'
)
s.table.loadtable(
   caslib = 'speech_model',
   casout = {'name':'pretrained_weights_attr','replace':True},
   path   = 'acoustic_model_cpu_weights_attr.sashdat'
)

# load the language model
s.table.loadtable(
   caslib = 'speech_model',
   casout = {'name':'language_model','replace':True},
   path   = 'language_model.sashdat'
)

# load the speaker model
s.table.loadtable(
   caslib = 'speech_model',
   casout = {'name':'cnn','replace':True},
   path   = 'speaker_model_cpu.sashdat'
)
s.table.loadtable(
   caslib = 'speech_model',
   casout = {'name':'myweights','replace':True},
   path   = 'speaker_model_cpu_weights.sashdat'
)
s.table.loadtable(
   caslib = 'speech_model',
   casout = {'name':'myweights.attr','replace':True},
   path   = 'speaker_model_cpu_weights_attr.sashdat'
)

# transcribe speech
s.langmodel.transcribespeech(
   acousticmodel  = {'model':{'name':'asr'},
                     'attributes':{'name':'pretrained_weights_attr'},
                     'weights':{'name':'pretrained_weights'}},
   casout         = {'name':'sample_output','replace':True},
   languagemodel  = {'model':{'name':'language_model'}},
   speakermodel   = {'model'      :{'name':'cnn'},
                     'attributes' :{'name':'myweights.attr'},
                     'weights'    :{'name':'myweights'},
                     'minSpeakers': 1,
                     'maxSpeakers': 2},
   table          = {'name':'sample_input'}
)

The following code shows how you can use the calculateErrorRate action to calculate the accuracy of the results if the true transcripts are available:

# load the true transcripts
s.table.loadtable(
   caslib = 'speech_data',
   casout = {'name':'sample_reference','replace':True},
   path   = 'sample_reference.sashdat'
)

# calculate the error rates
s.langmodel.calculateerrorrate(
   reference ={'name':'sample_reference'},
   table     ={'name':'sample_output'}
)

End-to-End Speech to Text Using the transcribeSpeech Action

This example is not available for the R programming language.

Last updated: August 04, 2026