tom-s / speak-tts

80 stars 20 forks source link

giving "voice" parameter at init will result an error on speak #5

Closed github0013 closed 6 years ago

github0013 commented 6 years ago

env

Problem

I just copied the readme example and ran it as below.

Speech.init({
    'onVoicesLoaded': (data) => {console.log('voices', data.voices)},
    'lang': 'en-US', // specify en-US language (no detection applied)
    'volume': 0.5,
    'rate': 0.8,
    'pitch': 0.8,
    'voice': 'Samantha'
})

Speech.speak({text: "Samantha"})  // error ..

A workaround I found... (or maybe I am not fully understand the APIs)

Instead, if I don't give voice parameter but later set the voice works fine.

Speech.init({
    'onVoicesLoaded': (data) => {console.log('voices', data.voices)},
    'lang': 'en-US', // specify en-US language (no detection applied)
    'volume': 0.5,
    'rate': 0.8,
    'pitch': 0.8
})

Speech.setVoice("Samantha")
Speech.speak({text: "Samantha"})
tom-s commented 6 years ago

Hi,

I have release a new version (2.0.3) which should solve the issue for you. Please note that the API has changed a bit and is now all promise-based.