Freezing of gait (FoG) is a common gait deficit in advanced Parkinson's disease (PD). FoG events are associated with falls, interfere with daily life activities and impair quality of life. FoG is often resistant to pharmacologic treatment; therefore effective non-pharmacologic assistance is needed. We propose a wearable assistant, composed of a smartphone and wearable accelerometers, for online detection of FoG. The system is based on machine learning techniques for automatic detection of FoG episodes. When FoG is detected, the assistant provides rhythmic auditory cueing or vibrotactile feedback that stimulates the patient to resume walking. We tested our solution on more than 8h of recorded lab data from PD patients that experience FoG in daily life. We characterize the system performance on user-dependent and user-independent experiments, with respect to different machine learning algorithms, sensor placement and preprocessing window size. The final system was able to detect FoG events with an average sensitivity and specificity of more than 95%, and mean detection latency of 0.34s in user-dependent settings.