File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ class _AsrWithDecoding(Asr):
4848
4949 def __init__ (self , preprocessor_name : str , vocab_path : Path , ** kwargs : Any ):
5050 self ._preprocessor = Preprocessor (preprocessor_name , ** kwargs )
51- with Path (vocab_path ).open ("rt" ) as f :
51+ with Path (vocab_path ).open ("rt" , encoding = "utf-8" ) as f :
5252 tokens = {token : int (id ) for token , id in (line .strip ("\n " ).split (" " ) for line in f .readlines ())}
5353 self ._vocab = {id : token for token , id in tokens .items ()}
5454 self ._blank_idx = tokens ["<blk>" ]
Original file line number Diff line number Diff line change @@ -31,16 +31,16 @@ def bytes_to_unicode() -> dict[int, str]:
3131
3232class _Whisper (Asr ):
3333 def __init__ (self , model_files : dict [str , Path ], ** kwargs : typing .Any ):
34- with model_files ["preprocessor_config" ].open () as f :
34+ with model_files ["preprocessor_config" ].open ("rt" , encoding = "utf-8" ) as f :
3535 preprocessor_config = json .load (f )
3636
3737 self ._input_length = preprocessor_config ["n_samples" ]
3838 self ._preprocessor = Preprocessor (f"whisper{ preprocessor_config ['feature_size' ]} " , ** kwargs )
3939
40- with model_files ["vocab" ].open () as f :
40+ with model_files ["vocab" ].open ("rt" , encoding = "utf-8" ) as f :
4141 self ._tokens : dict [str , int ] = json .load (f )
4242
43- with model_files ["added_tokens" ].open () as f :
43+ with model_files ["added_tokens" ].open ("rt" , encoding = "utf-8" ) as f :
4444 self ._tokens |= json .load (f )
4545
4646 self ._vocab = {id : token for token , id in self ._tokens .items ()}
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ def read_wav_files(waveforms: list[npt.NDArray[np.float32] | str]) -> list[npt.N
6262
6363def pad_list (arrays : list [npt .NDArray [np .float32 ]], axis : int = 0 ) -> tuple [npt .NDArray [np .float32 ], npt .NDArray [np .int64 ]]:
6464 """Pad list of Numpy arrays to common length."""
65- lens = np .array ([array .shape [axis ] for array in arrays ])
65+ lens = np .array ([array .shape [axis ] for array in arrays ], dtype = np . int64 )
6666 max_len = lens .max ()
6767
6868 def pads (array : npt .NDArray [np .float32 ]) -> list [tuple [int , int ]]:
You can’t perform that action at this time.
0 commit comments