OpenNMT translate string as an input

Is there a ready made version of the translate.py script that takes a string as input instead of a file?

Thanks.

Are you looking to use a translation server?

Not exactly, I wanted to call the inference model inside my code.

If you look at the code of the server, you will see that we can call the translate object with string rather than path.

so you can do something similar.

Great, thanks.