23
23
LOG = logging .getLogger (__name__ )
24
24
25
25
# Lock and event to ensure that the installation is executed before the tests
26
- INIT_VOSK_LOCK = threading .Lock ()
27
- INIT_FFMPEG_LOCK = threading .Lock ()
28
26
vosk_installed = threading .Event ()
29
27
ffmpeg_installed = threading .Event ()
30
28
installation_errored = threading .Event ()
@@ -41,49 +39,45 @@ def install_async():
41
39
return
42
40
43
41
def install_vosk (* args ):
44
- with INIT_VOSK_LOCK :
45
- if vosk_installed .is_set ():
46
- return
47
- try :
48
- LOG .info ("installing Vosk default version" )
49
- vosk_package .install ()
50
- LOG .info ("done installing Vosk default version" )
42
+ if vosk_installed .is_set ():
43
+ return
44
+ try :
45
+ LOG .info ("installing Vosk default version" )
46
+ vosk_package .install ()
47
+ LOG .info ("done installing Vosk default version" )
48
+ LOG .info ("downloading Vosk models used in test: %s" , PRE_DOWNLOAD_LANGUAGE_CODE_MODELS )
49
+ for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS :
50
+ model_name = LANGUAGE_MODELS [language_code ]
51
+ # downloading the model takes quite a while sometimes
52
+ TranscribeProvider .download_model (model_name )
51
53
LOG .info (
52
- "downloading Vosk models used in test: %s" , PRE_DOWNLOAD_LANGUAGE_CODE_MODELS
54
+ "done downloading Vosk model '%s' for language code '%s'" ,
55
+ model_name ,
56
+ language_code ,
53
57
)
54
- for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS :
55
- model_name = LANGUAGE_MODELS [language_code ]
56
- # downloading the model takes quite a while sometimes
57
- TranscribeProvider .download_model (model_name )
58
- LOG .info (
59
- "done downloading Vosk model '%s' for language code '%s'" ,
60
- model_name ,
61
- language_code ,
62
- )
63
- LOG .info ("done downloading all Vosk models used in test" )
64
- except Exception :
65
- LOG .exception ("Error during installation of Vosk dependencies" )
66
- installation_errored .set ()
67
- # we also set the other event to quickly stop the polling
68
- ffmpeg_installed .set ()
69
- finally :
70
- vosk_installed .set ()
58
+ LOG .info ("done downloading all Vosk models used in test" )
59
+ except Exception :
60
+ LOG .exception ("Error during installation of Vosk dependencies" )
61
+ installation_errored .set ()
62
+ # we also set the other event to quickly stop the polling
63
+ ffmpeg_installed .set ()
64
+ finally :
65
+ vosk_installed .set ()
71
66
72
67
def install_ffmpeg (* args ):
73
- with INIT_FFMPEG_LOCK :
74
- if ffmpeg_installed .is_set ():
75
- return
76
- try :
77
- LOG .info ("installing ffmpeg default version" )
78
- ffmpeg_package .install ()
79
- LOG .info ("done ffmpeg default version" )
80
- except Exception :
81
- LOG .exception ("Error during installation of Vosk dependencies" )
82
- installation_errored .set ()
83
- # we also set the other event to quickly stop the polling
84
- vosk_installed .set ()
85
- finally :
86
- ffmpeg_installed .set ()
68
+ if ffmpeg_installed .is_set ():
69
+ return
70
+ try :
71
+ LOG .info ("installing ffmpeg default version" )
72
+ ffmpeg_package .install ()
73
+ LOG .info ("done ffmpeg default version" )
74
+ except Exception :
75
+ LOG .exception ("Error during installation of Vosk dependencies" )
76
+ installation_errored .set ()
77
+ # we also set the other event to quickly stop the polling
78
+ vosk_installed .set ()
79
+ finally :
80
+ ffmpeg_installed .set ()
87
81
88
82
# we parallelize the installation of the dependencies
89
83
# TODO: we could maybe use a ThreadPoolExecutor to use Future instead of manually checking
0 commit comments