diff --git a/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSConstants.java b/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSConstants.java index 154d73fbd..5d0acbefc 100644 --- a/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSConstants.java +++ b/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSConstants.java @@ -25,7 +25,7 @@ public class PorcupineKSConstants { /** * Service name */ - public static final String SERVICE_NAME = "Porcupine Keyword Spotter"; + public static final String SERVICE_NAME = "Porcupine"; /** * Service id diff --git a/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSService.java b/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSService.java index c5174bae8..20c7b6f48 100644 --- a/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSService.java +++ b/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSService.java @@ -55,6 +55,7 @@ import org.osgi.framework.Constants; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Modified; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,8 +69,8 @@ import ai.picovoice.porcupine.PorcupineException; */ @NonNullByDefault @Component(configurationPid = SERVICE_PID, property = Constants.SERVICE_PID + "=" + SERVICE_PID) -@ConfigurableService(category = SERVICE_CATEGORY, label = SERVICE_NAME, description_uri = SERVICE_CATEGORY + ":" - + SERVICE_ID) +@ConfigurableService(category = SERVICE_CATEGORY, label = SERVICE_NAME + + " Keyword Spotter", description_uri = SERVICE_CATEGORY + ":" + SERVICE_ID) public class PorcupineKSService implements KSService { private static final String PORCUPINE_FOLDER = Path.of(OpenHAB.getUserDataFolder(), "porcupine").toString(); private static final String EXTRACTION_FOLDER = Path.of(OpenHAB.getUserDataFolder(), "porcupine", "extracted") @@ -98,8 +99,13 @@ public class PorcupineKSService implements KSService { @Activate protected void activate(ComponentContext componentContext, Map config) { - this.config = new Configuration(config).as(PorcupineKSConfiguration.class); this.bundleContext = componentContext.getBundleContext(); + modified(config); + } + + @Modified + protected void modified(Map config) { + this.config = new Configuration(config).as(PorcupineKSConfiguration.class); if (this.config.apiKey.isBlank()) { logger.warn("Missing pico voice api key to use Porcupine Keyword Spotter"); } @@ -288,8 +294,9 @@ public class PorcupineKSService implements KSService { + localKeywordPath); } String env = getPorcupineEnv(); - String keywordPath = "porcupine/resources/keyword_files/" + env + "/" + keyWord.replace(" ", "_") + "_" - + env + ".ppn"; + String keywordPath = Path + .of("porcupine", "resources", "keyword_files", env, keyWord.replace(" ", "_") + "_" + env + ".ppn") + .toString(); return prepareLib(bundleContext, keywordPath); } else { throw new IllegalArgumentException(