21
21
# SOFTWARE.
22
22
23
23
24
- from launch import LaunchDescription , LaunchContext
24
+ import os
25
25
from launch_ros .actions import Node
26
+ from launch import LaunchDescription , LaunchContext
27
+ from launch .conditions import IfCondition , UnlessCondition
26
28
from launch .substitutions import LaunchConfiguration , PythonExpression
27
- from launch .actions import OpaqueFunction , DeclareLaunchArgument
29
+ from launch .launch_description_sources import PythonLaunchDescriptionSource
30
+ from launch .actions import OpaqueFunction , DeclareLaunchArgument , IncludeLaunchDescription
31
+ from ament_index_python .packages import get_package_share_directory
28
32
from huggingface_hub import hf_hub_download
29
- from launch .conditions import IfCondition , UnlessCondition
30
33
31
34
32
35
def generate_launch_description ():
@@ -126,19 +129,42 @@ def run_whisper(context: LaunchContext, repo, file, model_path):
126
129
model_repo_cmd = DeclareLaunchArgument (
127
130
"model_repo" ,
128
131
default_value = "ggerganov/whisper.cpp" ,
129
- description = "Hugging Face model repo" ,
132
+ description = "Hugging Face model repo for Whisper " ,
130
133
)
131
134
132
135
model_filename = LaunchConfiguration ("model_filename" )
133
136
model_filename_cmd = DeclareLaunchArgument (
134
137
"model_filename" ,
135
138
default_value = "ggml-large-v3-turbo-q5_0.bin" ,
136
- description = "Hugging Face model filename" ,
139
+ description = "Hugging Face model filename for Whisper " ,
137
140
)
138
141
139
142
model_path = LaunchConfiguration ("model_path" )
140
143
model_path_cmd = DeclareLaunchArgument (
141
- "model_path" , default_value = "" , description = "Local path to the model file"
144
+ "model_path" ,
145
+ default_value = "" ,
146
+ description = "Local path to the model file for Whisper" ,
147
+ )
148
+
149
+ silero_vad_model_repo = LaunchConfiguration ("silero_vad_model_repo" )
150
+ silero_vad_model_repo_cmd = DeclareLaunchArgument (
151
+ "silero_vad_model_repo" ,
152
+ default_value = "onnx-community/silero-vad" ,
153
+ description = "Hugging Face model repo for SileroVAD" ,
154
+ )
155
+
156
+ silero_vad_model_filename = LaunchConfiguration ("silero_vad_model_filename" )
157
+ silero_vad_model_filename_cmd = DeclareLaunchArgument (
158
+ "silero_vad_model_filename" ,
159
+ default_value = "onnx/model.onnx" ,
160
+ description = "Hugging Face model filename for SileroVAD" ,
161
+ )
162
+
163
+ silero_vad_model_path = LaunchConfiguration ("silero_vad_model_path" )
164
+ silero_vad_model_path_cmd = DeclareLaunchArgument (
165
+ "silero_vad_model_path" ,
166
+ default_value = "" ,
167
+ description = "Local path to the model file for SileroVAD" ,
142
168
)
143
169
144
170
return LaunchDescription (
@@ -147,24 +173,30 @@ def run_whisper(context: LaunchContext, repo, file, model_path):
147
173
model_repo_cmd ,
148
174
model_filename_cmd ,
149
175
model_path_cmd ,
176
+ silero_vad_model_repo_cmd ,
177
+ silero_vad_model_filename_cmd ,
178
+ silero_vad_model_path_cmd ,
150
179
OpaqueFunction (
151
- function = run_whisper , args = [model_repo , model_filename , model_path ]
180
+ function = run_whisper ,
181
+ args = [model_repo , model_filename , model_path ],
152
182
),
153
- Node (
154
- package = "whisper_ros" ,
155
- executable = "silero_vad_node" ,
156
- name = "silero_vad_node" ,
157
- namespace = "whisper" ,
158
- parameters = [
159
- {
160
- "enabled" : LaunchConfiguration (
161
- "vad_enabled" ,
162
- default = PythonExpression ([LaunchConfiguration ("stream" )]),
163
- ),
164
- "threshold" : LaunchConfiguration ("vad_threshold" , default = 0.5 ),
165
- }
166
- ],
167
- remappings = [("audio" , "/audio/in" )],
183
+ IncludeLaunchDescription (
184
+ PythonLaunchDescriptionSource (
185
+ os .path .join (
186
+ get_package_share_directory ("whisper_bringup" ),
187
+ "launch" ,
188
+ "silero-vad.launch.py" ,
189
+ )
190
+ ),
191
+ launch_arguments = {
192
+ "enabled" : LaunchConfiguration (
193
+ "vad_enabled" ,
194
+ default = PythonExpression ([LaunchConfiguration ("stream" )]),
195
+ ),
196
+ "model_repo" : silero_vad_model_repo ,
197
+ "model_filename" : silero_vad_model_filename ,
198
+ "model_path" : silero_vad_model_path ,
199
+ }.items (),
168
200
),
169
201
Node (
170
202
package = "audio_common" ,
0 commit comments