mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[rustpotterks] Fix for Windows, avoid load library multiple times (#15945)
Signed-off-by: Miguel Álvarez <miguelwork92@gmail.com>
This commit is contained in:
parent
280fdb0962
commit
d498b492a0
@ -61,6 +61,7 @@ import io.github.givimad.rustpotter_java.ScoreMode;
|
||||
@ConfigurableService(category = SERVICE_CATEGORY, label = SERVICE_NAME
|
||||
+ " Keyword Spotter", description_uri = SERVICE_CATEGORY + ":" + SERVICE_ID)
|
||||
public class RustpotterKSService implements KSService {
|
||||
private boolean libraryLoaded;
|
||||
private static final String RUSTPOTTER_FOLDER = Path.of(OpenHAB.getUserDataFolder(), "rustpotter").toString();
|
||||
private final Logger logger = LoggerFactory.getLogger(RustpotterKSService.class);
|
||||
private final ScheduledExecutorService executor = ThreadPoolManager.getScheduledPool("OH-voice-rustpotterks");
|
||||
@ -109,11 +110,14 @@ public class RustpotterKSService implements KSService {
|
||||
@Override
|
||||
public KSServiceHandle spot(KSListener ksListener, AudioStream audioStream, Locale locale, String keyword)
|
||||
throws KSException {
|
||||
logger.debug("Loading library");
|
||||
try {
|
||||
Rustpotter.loadLibrary();
|
||||
} catch (IOException e) {
|
||||
throw new KSException("Unable to load rustpotter lib: " + e.getMessage());
|
||||
if (!libraryLoaded) {
|
||||
logger.debug("Loading library");
|
||||
try {
|
||||
Rustpotter.loadLibrary();
|
||||
libraryLoaded = true;
|
||||
} catch (IOException e) {
|
||||
throw new KSException("Unable to load rustpotter lib: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
var audioFormat = audioStream.getFormat();
|
||||
var frequency = audioFormat.getFrequency();
|
||||
|
Loading…
Reference in New Issue
Block a user