tom-s / speak-tts

80 stars 20 forks source link

initialization problem on mobile #6

Closed nazarparuna closed 6 years ago

nazarparuna commented 6 years ago

I have a problem with speaking on mobile (Android-Chrome, IOS-Safari). I call Speech.init() method from constructor of component. I put alert in 'onVoicesLoaded' function, so i see that it works, after that I try to speak some sentences, but there is no voice. I have some button on UI, so when i click them it starts speaking. On Linux with Chrome it works perfect. I load page, voices are loaded, I hear a speech. I will be very glad to get response from you)

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.

nazarparuna commented 6 years ago

Hello, I tried new version, but there are still issues. On Android I put alert in then(), but it does not work every time. On iOS I cannot hear/see anything. Let me explain: I don't hear voice, don't see alert that initialization failed and don't see alert that speaking failed. I put my test example here. I will appreciate any help.

tom-s commented 6 years ago

Hi. Could you specify which version of android and ios and which browser you are using ? Is the demo link in the readme file working for you ?

tom-s commented 6 years ago

Ive just tried the demo link on ios12 on safari with an iphone and it works. Perhaps you have a different version ?

nazarparuna commented 6 years ago

Hi. Could you specify which version of android and ios and which browser you are using ? Is the demo link in the readme file working for you ?

I use Android 8.1 ( Chrome Beta) and iOS 11 (Safari 11). Yes, demo works.

tom-s commented 6 years ago

There is a known bug on android which sometimes make the voice loading fail. I will fix this with a workaround in the next version. Regarding ios if the demo link works I cant see a particular reason why it wouldnt work on your project 😢

nazarparuna commented 6 years ago

Have only one question on iOS does it trigger first phrase 'If you hear my...'?

tom-s commented 6 years ago

Im sorry I dont understand the question. Could you rephase please ?

nazarparuna commented 6 years ago

When you tried my test example on iOS. The first phrase was 'If you here my voice...'?

tom-s commented 6 years ago

Sorry I cannot try your example imi on holidays and away from any computer. I just tried my demo link on my sisters iphone and my android phone 😀

tom-s commented 6 years ago

Is your speech synthesis triggered by a user action such as a click ? I believe on ios it needs to be . If not try to plug it on a click event and see if it makes any difference

nazarparuna commented 6 years ago

Is your speech synthesis triggered by a user action such as a click ? I think on ios it needs to be

No, I tried to trigger it after init this.speech.init().then((data)=>{ this.speech.speak({ text : this.text }).then((d) => { alert('finish speak'); })

tom-s commented 6 years ago

That would be the reason of your problem then, apple doesnt allow speech synthesis without a user action

nazarparuna commented 6 years ago

Is it described anywhere?

tom-s commented 6 years ago

I cant find any official link from apple but the problem is mentionned by various people on many stack overflow pages and blog posts. Also this s a common problem with many web apis and ios. You can particularly check out rosskyl answer on this thread. https://github.com/Microsoft/BotFramework-WebChat/issues/995 I will do a fix soon for the android issue but consider the ios problem resolved. Ill add a section for ios in the readme

nazarparuna commented 6 years ago

Thank you a lot. I will be waiting for your new version

tom-s commented 6 years ago

No worries. Ill probably do it this weekend when I get back to france.

tom-s commented 6 years ago

Hi @nazarparuna . I've published version 2.0.6 (https://www.npmjs.com/package/speak-tts) which should solve your issues on android. Please let me know how it goes !

tom-s commented 6 years ago

Please note that there is no more onVoicesLoaded function. you can either retrieve the voices from the data passed to the resolved init() Promise, or use the props 'listeners' to add an 'onvoiceschanged' listener.

tom-s commented 6 years ago

@nazarparuna: may I close this issue ?

nazarparuna commented 6 years ago

Yeah. Sure. Thank you