"""wake_word.launch.py — Launch wake-word detector ('hey salty') (Issue #320).

Usage:
  ros2 launch saltybot_social wake_word.launch.py
  ros2 launch saltybot_social wake_word.launch.py template_path:=/opt/saltybot/models/hey_salty.npy
  ros2 launch saltybot_social wake_word.launch.py match_threshold:=0.85 cooldown_s:=3.0
"""

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description():
    pkg = get_package_share_directory("saltybot_social")
    cfg = os.path.join(pkg, "config", "wake_word_params.yaml")

    return LaunchDescription([
        DeclareLaunchArgument("template_path",    default_value="",
                              description="Path to .npy template file (log-mel of 'hey salty')"),
        DeclareLaunchArgument("match_threshold",  default_value="0.82",
                              description="Cosine-similarity detection threshold"),
        DeclareLaunchArgument("cooldown_s",       default_value="2.0",
                              description="Minimum seconds between detections"),

        Node(
            package="saltybot_social",
            executable="wake_word_node",
            name="wake_word_node",
            output="screen",
            parameters=[
                cfg,
                {
                    "template_path":   LaunchConfiguration("template_path"),
                    "match_threshold": LaunchConfiguration("match_threshold"),
                    "cooldown_s":      LaunchConfiguration("cooldown_s"),
                },
            ],
        ),
    ])
