Search code examples
pythonflaskvirtualenvpocketsphinx

Flask and running a script on server VS running in terminal : Different results?


Just started with Flask and Python yesterday so this may be a stupid question, but what is the difference between running a Python script via flask:5000 server and running it locally?

I have a script that uses pocketsphinx and it works 100% correctly when I run it in my terminal but when I call it from my flask site it gets an error.

There error is:

"acmod.c", line 83: Folder 'reqs/model/en-us/en-us' does not contain acoustic model definition 'mdef'

It doesn't make sense to me since my views.py script is in the same folder that 'reqs' is in and the mdef file IS located in 'reqs/model/en-us/en-us' so I'd think the path would work.

And it works when ran in terminal, just not on the flask site.


Solution

  • I was able to fix this issue by simply passing the flask app.root_path variable into my python script and adding it in front of 'reqs/model/en-us/en-us' so I guess I needed to have an absolute path instead of a relative one.