From b34c0ba379c8cc46e32980fc73759172cd9aab36 Mon Sep 17 00:00:00 2001 From: yasutomo57jp Date: Tue, 23 May 2023 17:09:28 +0900 Subject: [PATCH] the model and the target language are parametrized --- launch/ros2_whisper.launch.py | 1 + ros2_whisper/whisper_inference_node.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/launch/ros2_whisper.launch.py b/launch/ros2_whisper.launch.py index d2f2ae1..2c888b6 100644 --- a/launch/ros2_whisper.launch.py +++ b/launch/ros2_whisper.launch.py @@ -17,6 +17,7 @@ def generate_launch_description(): package="ros2_whisper", executable="whisper_inference_node", output="screen", + parameters=[{"model": "base", "lanaguage": "english"}], ) whisper_inference_node_event_handler = RegisterEventHandler( diff --git a/ros2_whisper/whisper_inference_node.py b/ros2_whisper/whisper_inference_node.py index 460c1c8..270c78c 100644 --- a/ros2_whisper/whisper_inference_node.py +++ b/ros2_whisper/whisper_inference_node.py @@ -12,8 +12,13 @@ class WhisperInferenceNode(Node): def __init__(self, node_name: str) -> None: super().__init__(node_name) - self.whisper_model_ = whisper.load_model("base") - self.whisper_options_ = whisper.DecodingOptions(language="english") + self.declare_parameter("model", "base") + self.declare_parameter("language", "english") + model = self.get_parameter("model").value + language = self.get_parameter("language").value + + self.whisper_model_ = whisper.load_model(model) + self.whisper_options_ = whisper.DecodingOptions(language=language) self.declare_parameters( namespace="",