unicode error when calling windows terminal from RStudio but not R

40 views Asked by At

I have an .exe that's meant to be called from the terminal/command line, and I want to use R to generate the program calls, iterate over different arguments, measure timings, capture output, and so forth.

The executable is whisper-standalone-win. From windows command line (cmd.exe), after cd'ing to the executable, we can do for example:

whisper-faster.exe --help

In R terminal (R.exe), we can do:

shell("whisper-faster.exe --help")

These both function as intended. However, in RStudio, I get:

#> [1] "Traceback (most recent call last):"                                                                                   
#> [2] "  File \"D:\\whisper-fast\\__main__.py\", line 666, in <module>"                                                      
#> [3] "  File \"D:\\whisper-fast\\__main__.py\", line 365, in cli"                                                           
#> [4] "  File \"argparse.py\", line 1768, in parse_args"                                                                     
#> [5] "  File \"argparse.py\", line 1800, in parse_known_args"                                                               
#> [6] "  File \"argparse.py\", line 2006, in _parse_known_args"                                                              
#> [7] "  File \"argparse.py\", line 1946, in consume_optional"                                                               
#> [8] "  File \"argparse.py\", line 1874, in take_action"                                                                    
#> [9] "  File \"argparse.py\", line 1044, in __call__"                                                                       
#> [10] "  File \"argparse.py\", line 2494, in print_help"                                                                     
#> [11] "  File \"argparse.py\", line 2500, in _print_message"                                                                 
#> [12] "  File \"encodings\\cp1252.py\", line 19, in encode"                                                                  
#> [13] "UnicodeEncodeError: 'charmap' codec can't encode character '\\u3002' in position 12754: character maps to <undefined>"
#> [14] "[23996] Failed to execute script '__main__' due to unhandled exception!"                                              
#> attr(,"status")
#> [1] 1

(I'm using --help as a simple example; this error also occurs with normal usage with an input audio file.) I've tried system() and system2() without luck. I'm aware of threads here and here about unicode errors with whisper, though it's not clear to me how to apply them to this usage.

I'm thinking of this as a sort of general problem of how to make sure I get the same results with RStudio as I do with cmd and R terminal. I'd really like to be able to do everything from the comfort of RStudio.

I'm on Windows 10 if that's important. I've tried Sys.setenv(LANG = "en_US.UTF-8") and a few other variations, also without success.

0

There are 0 answers