mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-27 07:41:39 +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
|
@ConfigurableService(category = SERVICE_CATEGORY, label = SERVICE_NAME
|
||||||
+ " Keyword Spotter", description_uri = SERVICE_CATEGORY + ":" + SERVICE_ID)
|
+ " Keyword Spotter", description_uri = SERVICE_CATEGORY + ":" + SERVICE_ID)
|
||||||
public class RustpotterKSService implements KSService {
|
public class RustpotterKSService implements KSService {
|
||||||
|
private boolean libraryLoaded;
|
||||||
private static final String RUSTPOTTER_FOLDER = Path.of(OpenHAB.getUserDataFolder(), "rustpotter").toString();
|
private static final String RUSTPOTTER_FOLDER = Path.of(OpenHAB.getUserDataFolder(), "rustpotter").toString();
|
||||||
private final Logger logger = LoggerFactory.getLogger(RustpotterKSService.class);
|
private final Logger logger = LoggerFactory.getLogger(RustpotterKSService.class);
|
||||||
private final ScheduledExecutorService executor = ThreadPoolManager.getScheduledPool("OH-voice-rustpotterks");
|
private final ScheduledExecutorService executor = ThreadPoolManager.getScheduledPool("OH-voice-rustpotterks");
|
||||||
@ -109,12 +110,15 @@ public class RustpotterKSService implements KSService {
|
|||||||
@Override
|
@Override
|
||||||
public KSServiceHandle spot(KSListener ksListener, AudioStream audioStream, Locale locale, String keyword)
|
public KSServiceHandle spot(KSListener ksListener, AudioStream audioStream, Locale locale, String keyword)
|
||||||
throws KSException {
|
throws KSException {
|
||||||
|
if (!libraryLoaded) {
|
||||||
logger.debug("Loading library");
|
logger.debug("Loading library");
|
||||||
try {
|
try {
|
||||||
Rustpotter.loadLibrary();
|
Rustpotter.loadLibrary();
|
||||||
|
libraryLoaded = true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new KSException("Unable to load rustpotter lib: " + e.getMessage());
|
throw new KSException("Unable to load rustpotter lib: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var audioFormat = audioStream.getFormat();
|
var audioFormat = audioStream.getFormat();
|
||||||
var frequency = audioFormat.getFrequency();
|
var frequency = audioFormat.getFrequency();
|
||||||
var bitDepth = audioFormat.getBitDepth();
|
var bitDepth = audioFormat.getBitDepth();
|
||||||
|
Loading…
Reference in New Issue
Block a user