Solution for background sound & speech synth
- Tình trạng: Closed
- Giải thưởng: €50
- Các bài thi đã nhận: 5
- Người chiến thắng: bongbong88
Tóm tắt cuộc thi
I need an app, which plays an audio file and speak outs a text string with Speech Synthesizer. Piece of cake so far but: This must work when the screen is locked – The playback WILL START when the screen is locked. Also it must support other background music played all the time, and they are faded a bit, when our sound and speech synth is played. This is called ducking. So the workflow would be:
- First open some music app, like spotify, iTunes or whatever which plays music on the background
- Then open this app, lets call it OURAPP. There is only one button in OURAPP. The button calls a function, which waits few seconds (e.g. three seconds) and then plays an audio file (with AV audio player, not sound effect) and after that a speech synthesizer reads some string, eg. "hello world, tomorrow is tomorrow!"
- When the button is tapped and timer is triggered, we lock the screen of the device
- When the timer of three seconds is gonna and the actual function is fired, we hear the audio file and the speech while the background music is ducked (aka volume is lowered). All this when screen is locked.
- After the audio file and speech is spoken, the background music comes back again. The volume ducking can be made for fixed time, for example 4 seconds, no matter how long our speech will take.
- No matter what is the status of the mute switch on the phone, the audio file and speech string can be heard. When adjusted volume with the buttons of the device, they will naturally affect the playback volume of the speech and audio.
- A volume slider for the sound and speech synth in the main menu along our only button is a good bonus
- Support for iOS7 onwards, test with device with iOS 8.3. ObjC preferred. All written programmatically.
- Commented so that the solution can be easily integrated to an existing app.
NOTE: When using normal av audio player and speech syntehsizer methods, the case seems to work out-of-the-box with 8.3 simulator. But on a device it doesn't work! I believe in this case the simulator works wrong, and the device works OK. It makes sense that with normal audio player the app must be active when it is started, and then it can be left playing on the background. But if we want to play sound when the app is already on the background, we must use some other technique. But I presume You know this already! :)
AGAIN: The tricky thing is that playing with audio sessions categories and using normal methods for playing sounds and using speech synthesizer, the app must be ACTIVE when the playback starts. But in our case the screen is LOCKED when the playback starts. Using the "System Sound" for playing the wav does not work here, since it obeys the mute switch. All sounds must be heard even if the phone is muted.
I need a quick solutions, so start coding! :)
Also the app must work as planned, if the app is put on background. As described above, it works when screen is locked AND if home button is pressed and other apps are active or whatever. Think of it as a sport tracker app giving you split times no matter what is the situation with the app's status (foreground/background/locked screen) Also all Apple's guidelines must be met, so playing out silence is not permitted. :)