{"action":"opened","issue":{"url":"https://api.github.com/repos/librosa/librosa/issues/360","repository_url":"https://api.github.com/repos/librosa/librosa","labels_url":"https://api.github.com/repos/librosa/librosa/issues/360/labels{/name}","comments_url":"https://api.github.com/repos/librosa/librosa/issues/360/comments","events_url":"https://api.github.com/repos/librosa/librosa/issues/360/events","html_url":"https://github.com/librosa/librosa/issues/360","id":155050003,"number":360,"title":"Trim leading and trailing silence in `load`","user":{"login":"carlthome","id":1595907,"avatar_url":"https://avatars.githubusercontent.com/u/1595907?v=3","gravatar_id":"","url":"https://api.github.com/users/carlthome","html_url":"https://github.com/carlthome","followers_url":"https://api.github.com/users/carlthome/followers","following_url":"https://api.github.com/users/carlthome/following{/other_user}","gists_url":"https://api.github.com/users/carlthome/gists{/gist_id}","starred_url":"https://api.github.com/users/carlthome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlthome/subscriptions","organizations_url":"https://api.github.com/users/carlthome/orgs","repos_url":"https://api.github.com/users/carlthome/repos","events_url":"https://api.github.com/users/carlthome/events{/privacy}","received_events_url":"https://api.github.com/users/carlthome/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-16T15:09:39Z","updated_at":"2016-05-16T15:09:39Z","closed_at":null,"body":"Would it make sense to add a way of trimming silence when loading audio? Currently I'm doing this silliness, which works alright aside from being performance intensive, but the onset detector surely isn't built for detecting offsets like this, I'd assume.\r\n\r\n```Python\r\npath = ... # Path to an audio file with a bunch of leading and trailing silence.\r\ny, sr = librosa.load(path, sr=None)\r\nonsets = librosa.frames_to_time(librosa.onset.onset_detect(y, sr), sr)\r\noffsets = librosa.frames_to_time(librosa.onset.onset_detect(y[::-1], sr), sr)  # Suboptimal!\r\nleading_silence = onsets[0]\r\ntrailing_silence = offsets[0]\r\ntotal_duration = librosa.get_duration(y, sr)\r\ny, _ = librosa.load(path, sr, offset=leading_silence, duration=total_duration-leading_silence-trailing_silence)\r\n```\r\n\r\nAlso, perhaps if loading with a set duration longer than the actual file, then there should be the option of padding the sequence to the set length, or at least provide a user warning that less than `duration` was loaded."}}