Skip to content

A Vaadin Addon that allows usage of SpeechRecognition and SpeechSynthesis JS API

License

Notifications You must be signed in to change notification settings

manolo/addon-voice-engine

Repository files navigation

Voice Addon

An addon for voice recognition and speach text

Example

@Route("")
public class VoiceEngineView extends Div {

    public VoiceEngineView() {
        setSizeFull();

        Button clearButton = new Button(LumoIcon.CROSS.create());
        VoiceEngine voiceEngine = new VoiceEngine().setButtons(MICROPHONE, PLAY, LANG, VOICE);
        voiceEngine.add(clearButton);
        TextArea textArea = new TextArea();

        textArea.setSizeFull();
        add(new VerticalLayout(voiceEngine, textArea));

        clearButton.addClickListener(e -> textArea.clear());
        voiceEngine.addStartListener(e -> textArea.clear());
        textArea.addValueChangeListener(e -> voiceEngine.setSpeech(e.getValue()));

        voiceEngine.addEndListener(e -> {
            if (voiceEngine.getRecorded() != null) {
                textArea.setValue(voiceEngine.getRecorded());
            }
            if (!textArea.getValue().isEmpty()) {
                voiceEngine.setSpeech(voiceEngine.getRecorded());
            }
        });
    }
}

About

A Vaadin Addon that allows usage of SpeechRecognition and SpeechSynthesis JS API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published