algolia / voice-overlay-ios

🗣 An overlay that gets your user’s voice permission and input as text in a customizable UI
https://alg.li/voice
MIT License
544 stars 62 forks source link

Problem in SpeechController #10

Closed vijaykharage closed 5 years ago

vijaykharage commented 5 years ago

After recording has done I want to speak out loud the text what I just said. But I guess there is still SpeechController running in background even though SpeechController.stopRecording() method calls from deinit. I am trying to use this code

let string = "Hello, World!"
let utterance = AVSpeechUtterance(string: string)
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")

let synth = AVSpeechSynthesizer()
synth.speak(utterance)

But no utterance is happening. Please help me.

spinach commented 5 years ago

Hey @vijaykharage ,

I just quickly tested your snippet in the demo project by adding your sample in the textHandler and it worked fine (I could hear the "Hello World!". Do you have some sample code project so that we can reproduce the issue?

vijaykharage commented 5 years ago

Please tell me that, are you testing it as soon as the recording has finished? Because I am and not hearing anything rather I ran it in another viewController and it does well (Before recording anything).

spinach commented 5 years ago

Yes, I am testing it in the handler as soon as it is finished, and it works fine in the demo. Check in the speech_test branch, the demo. This is the line concerned. You can checkout the branch and run the demo and see for yourself

vijaykharage commented 5 years ago

Did the same. It is running perfectly fine on simulator but in device there is something weird stuff I am seeing. Please look following GIF. ezgif-4-da283ecb5daf

The music widget is looking fine. But after I press mic button and then see that music widget, some icon appear on upper right corner. I guess the app is still listening. Any suggestions would be very appreciated.

spinach commented 5 years ago

I see, that's weird.. In order to debug, I suggest you check this part of the README to have access to the SpeechController under the hood. Then you can debug and try to stop the speech controller manually, and see if this fixes the issue? Let me know what you find out.