Search in sources :

Example 1 with AudioSource

use of org.eclipse.smarthome.core.audio.AudioSource in project smarthome by eclipse.

the class AudioManagerImpl method getParameterOptions.

@Override
public Collection<ParameterOption> getParameterOptions(URI uri, String param, Locale locale) {
    if (uri.toString().equals(CONFIG_URI)) {
        if (CONFIG_DEFAULT_SOURCE.equals(param)) {
            List<ParameterOption> options = new ArrayList<>();
            for (AudioSource source : audioSources.values()) {
                ParameterOption option = new ParameterOption(source.getId(), source.getLabel(locale));
                options.add(option);
            }
            return options;
        } else if (CONFIG_DEFAULT_SINK.equals(param)) {
            List<ParameterOption> options = new ArrayList<>();
            for (AudioSink sink : audioSinks.values()) {
                ParameterOption option = new ParameterOption(sink.getId(), sink.getLabel(locale));
                options.add(option);
            }
            return options;
        }
    }
    return null;
}
Also used : AudioSource(org.eclipse.smarthome.core.audio.AudioSource) AudioSink(org.eclipse.smarthome.core.audio.AudioSink) ParameterOption(org.eclipse.smarthome.config.core.ParameterOption) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with AudioSource

use of org.eclipse.smarthome.core.audio.AudioSource in project smarthome by eclipse.

the class VoiceManagerImpl method startDialog.

@Override
public void startDialog(KSService ksService, STTService sttService, TTSService ttsService, HumanLanguageInterpreter interpreter, AudioSource audioSource, AudioSink audioSink, Locale locale, String keyword, String listeningItem) {
    // use defaults, if null
    KSService ks = (ksService == null) ? getKS() : ksService;
    STTService stt = (sttService == null) ? getSTT() : sttService;
    TTSService tts = (ttsService == null) ? getTTS() : ttsService;
    HumanLanguageInterpreter hli = (interpreter == null) ? getHLI() : interpreter;
    AudioSource source = (audioSource == null) ? audioManager.getSource() : audioSource;
    AudioSink sink = (audioSink == null) ? audioManager.getSink() : audioSink;
    Locale loc = (locale == null) ? localeProvider.getLocale() : locale;
    String kw = (keyword == null) ? this.keyword : keyword;
    String item = (listeningItem == null) ? this.listeningItem : listeningItem;
    if (ks != null && stt != null && tts != null && hli != null && source != null && sink != null && loc != null && kw != null) {
        DialogProcessor processor = new DialogProcessor(ks, stt, tts, hli, source, sink, loc, kw, item, this.eventPublisher);
        processor.start();
    } else {
        String msg = "Cannot start dialog as services are missing.";
        logger.error(msg);
        throw new IllegalStateException(msg);
    }
}
Also used : AudioSource(org.eclipse.smarthome.core.audio.AudioSource) AudioSink(org.eclipse.smarthome.core.audio.AudioSink) Locale(java.util.Locale) STTService(org.eclipse.smarthome.core.voice.STTService) KSService(org.eclipse.smarthome.core.voice.KSService) TTSService(org.eclipse.smarthome.core.voice.TTSService) HumanLanguageInterpreter(org.eclipse.smarthome.core.voice.text.HumanLanguageInterpreter)

Aggregations

AudioSink (org.eclipse.smarthome.core.audio.AudioSink)2 AudioSource (org.eclipse.smarthome.core.audio.AudioSource)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Locale (java.util.Locale)1 ParameterOption (org.eclipse.smarthome.config.core.ParameterOption)1 KSService (org.eclipse.smarthome.core.voice.KSService)1 STTService (org.eclipse.smarthome.core.voice.STTService)1 TTSService (org.eclipse.smarthome.core.voice.TTSService)1 HumanLanguageInterpreter (org.eclipse.smarthome.core.voice.text.HumanLanguageInterpreter)1