allosaurus icon indicating copy to clipboard operation
allosaurus copied to clipboard

How do you use a prior file from within python?

Open seis640a opened this issue 10 months ago • 2 comments

Is it possible to use the prior customization file from within a python application? If not, is there an easy workaround? Thank you, Mike

seis640a avatar Feb 18 '25 13:02 seis640a

the same as your question, when I use prior argument within a python application, the following issues:recognize() got an unexpected keyword argument 'prior'

beyondyourselfjiang avatar Feb 26 '25 01:02 beyondyourselfjiang

I ran into a similar issue trying to get it to run on my GPU. It's not really all that hard, just a PITA. Basically, read_recognize() takes either the model name as a string, or an argparse Namespace. So, in order to really use it in python, you need to rebuild the argparse Namespace that's created in run.py. Here's a sample of code that rebuilds the default:

import argparse
import allosaurus.model

args = argparse.Namespace()

args.device_id = -1
args.model = allosaurus.model.resolve_model_name('latest')
args.lang = 'ipa'
args.topk = 1
args.timestamp = False
args.prior = None
args.emit = 1.0
args.approximate = False

2001herne avatar Sep 04 '25 05:09 2001herne