Code Monkey home page Code Monkey logo

Comments (4)

sdkcarlos avatar sdkcarlos commented on May 18, 2024

Hi, if you're not using voice commands you don't need the redirectRecognizedTextOutput function.

You can retrieve the recognized text from the dictation object in the onResult callback. Note that you have already set some event listeners to the buttons (start and stop) with jQuery, therefore isn't necessary to add new actions in the onclick attribute of the buttons.

The following code is the same as yours but simplified (and working):

<!-- Buttons to start the dictation object -->
<input class="buttonRoundVoiceToTextWhite" type="button" value="Recognize text" />
<input class="buttonRoundVoiceToTextBlue hidden" type="button" value="stop recognition" />

<!-- In this input the recognized text will appear -->
<input id="artyom-redirect-output" type="text" name="lastname">

<script>
    // Configure artyom
    var UserDictation = artyom.newDictation({
        continuous: true, // Don't stop never because i have https connection
        onResult: function (text) {
            /** 
             * Set the recognized text as value of the text input
            **/
            $("#artyom-redirect-output").val(text);
        },
        onStart: function () {
            console.log("Dictation started by the user");
        },
        onEnd: function () {
            alert("Dictation stopped by the user");
        }
    });

    var btnAnimWhite = $(".buttonRoundVoiceToAnimWhite");
    var btnAnimBlue = $(".buttonRoundVoiceToAnimBlue");
    var btnVoiceTextWhite = $(".buttonRoundVoiceToTextWhite");
    var btnVoiceTextBlue = $(".buttonRoundVoiceToTextBlue");

    btnAnimWhite.click(function () {
        btnAnimBlue.show();
        btnAnimWhite.hide();
    });

    btnAnimBlue.click(function () {
        btnAnimWhite.show();
        btnAnimBlue.hide();
    });

    // Start recognition with the Recognize text button
    btnVoiceTextWhite.click(function () {
        // Start recognition
        UserDictation.start();

        btnVoiceTextBlue.show();
        btnVoiceTextWhite.hide();
    });

    // Stop recognition with the Stop recognition button
    btnVoiceTextBlue.click(function () {
        // Stop recognition
        UserDictation.stop();

        btnVoiceTextWhite.show();
        btnVoiceTextBlue.hide();
    });

</script>

The language of the dictation object will be the same as the one providen with the initialization.

As the problem isn't related to the library, this issue can be closed.

from artyom.js.

popbijoux avatar popbijoux commented on May 18, 2024

THANK YOU so much Carlos!!!! Just tested it it works perfectly YAAYYYY it's like magic:))))

from artyom.js.

popbijoux avatar popbijoux commented on May 18, 2024

Hi there carlos I was able to use this and it worked very well. I have a question related to switching languages in the browser, similar to how you used it in this application
https://sdkcarlos.github.io/demo-sites/artyom/artyom_sticky_notes.html

Basically I am wondering if it's possible to have a command that will tell artyom to switch the language that it is recognizing. For example I am bilingual in English and Portuguese. Is there a way to have a command that will switch the language after it has been initialized.

If I say for example "Switch to Portuguese", and vice-versa, once the browser recognizes speech in Portuguese, I create a command that will tell it to go back to English. I see how you have the drop-down menu for several languages in the example above. It worked but it was not done via a speech command.

I am not sure if 1. It can be done via command as opposed to clicking on browser button and 2. If not, how can I create a simple switch function that would allow me to move between 2 separate languages (and display the text like I did using the example above I used in the past?

Thank you. I am not sure if I should post this as a separate question or continue here.

from artyom.js.

sdkcarlos avatar sdkcarlos commented on May 18, 2024

Hi @popbijoux , sorry for the late reply. Indeed, starting from scratch and doing it with the new version of Artyom could be tricky, therefore I wrote a detailed article with examples of how to switch from one language to other (multiple languages) using a single instance of Artyom or multiple. You can find the article here.

from artyom.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.