Skip to content

Commit

Permalink
the model and the target language are parametrized
Browse files Browse the repository at this point in the history
  • Loading branch information
yasutomo57jp committed May 23, 2023
1 parent fb8120a commit b34c0ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions launch/ros2_whisper.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 7 additions & 2 deletions ros2_whisper/whisper_inference_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="",
Expand Down

0 comments on commit b34c0ba

Please sign in to comment.