def detect_leading_silence(sound, silence_threshold, chunk_size=10):
    """ Iterate over audio chunks until you find the first one with sound

    sound is a pydub.AudioSegment
    silence_threshold in dBFS
    chunk_size in ms
    """
    trim_ms = 0 # ms

    assert chunk_size > 0 # to avoid infinite loop
    while sound[trim_ms:trim_ms+chunk_size].dBFS < silence_threshold and trim_ms < len(sound):
        trim_ms += chunk_size

    return trim_ms