stephenlb / spoken

Spoken - JavaScript Text-to-Speech and Speech-to-Text for AI Artificial Intelligence Apps
https://stephenlb.github.io/spoken/
73 stars 11 forks source link

import spoken from 'spoken' dont work #2

Closed LuizLeite closed 6 years ago

LuizLeite commented 6 years ago

Hi.

How to use with: "import spoken from 'spoken'?

Can you given a example with Webpack?

Tanks.

stephenlb commented 6 years ago

Checking into this.

stephenlb commented 6 years ago

Making updates and will post them!

stephenlb commented 6 years ago

Almost done...

stephenlb commented 6 years ago

Added support for modules.

<script type="module">

    import spoken from './node_modules/spoken/build/spoken.js';

    spoken.say('Should I turn the hallway light on?').then( speech => {
        spoken.listen().then( transcript =>
            console.log("Answer: " + transcript) )
    } )

</script>
LuizLeite commented 6 years ago

Tanks. I will try it. Luiz Leite

Em sexta-feira, 3 de agosto de 2018 18:20:54 BRT, Stephen L. Blum <notifications@github.com> escreveu:  

Added support for modules.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

stephenlb commented 6 years ago

Sweet!

LuizLeite commented 6 years ago

Hi. More one question. How to choose a voice to speek? There are two pt-BR in list of voices. Tank you again. Luiz Leite

Em sexta-feira, 3 de agosto de 2018 19:26:03 BRT, Stephen L. Blum <notifications@github.com> escreveu:  

Sweet!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

stephenlb commented 6 years ago

By default 'pt-BR' was selected automatically for you spoken.recognition.language = navigator.language;. You can get a list of voices using the following example:

// Set native voice language
spoken.recognition.language = 'en-US';

// Get a List of Voices with promise callback
spoken.voices().then( voices => console.log(voices) );

Here is a full example:

(async function() {
    // List of English Speaking Voices
    spoken.recognition.language = navigator.language || 'en-US';
    let voices = (await spoken.voices()).filter( v => !v.lang.indexOf('en') );

    // Use the First Voice
    spoken.say( 'Welcome to flavor town.', voices[0] );
})()