Librosa Trim vs SOX Trim
See original GitHub issueDescription
Help with Librosa trim and understanding it.
Steps/Code to Reproduce
import librosa
trimmed, _ = librosa.effects.trim(signal)
plot_waveform([trimmed[:1000]])
print(librosa.get_duration(signal), librosa.get_duration(trimmed))
Expected Results
Expecting the first ~400 samples to be trimmed.
Actual Results
6.195238095238095 6.195238095238095
Versions
Darwin-17.5.0-x86_64-i386-64bit Python 3.6.5 (default, May 15 2018, 11:11:58) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] NumPy 1.14.3 SciPy 1.1.0 librosa 0.6.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
librosa.effects.trim — librosa 0.10.0.dev0 documentation
Trim leading and trailing silence from an audio signal. Parameters. ynp.ndarray, shape=(…, n). Audio signal. Multi-channel is supported.
Read more >Use Python to trim and pad wav file using sox without saving ...
Save this question. Show activity on this post. I found that the best way to trim and pad wav files is to use...
Read more >What are some python packages I can use to cut audio files
The librosa library is usually used. ... The most basic approach probably would be to use scipy 's read and write functions for...
Read more >librosa.effects.trim — librosa 0.6.0 documentation
Trim leading and trailing silence from an audio signal. Parameters: y : np.ndarray, shape=(n,) or (2, ...
Read more >Basic Audio Handling - Medium
1st part: how to use ffmpeg and sox to handle audio files ... To trim an audio file, e.g. from the 60th to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a bit difficult to diagnose without access to the original signal.
For clarification, what
trim
does is clip off frames at the beginning or end of the clip where the rmse is significantly below the reference value. By default, the reference value is the max over all frames, and the threshold for “significant” is 60dB. The framing parameters are aligned to the library defaults (n=2048, hop=512). In your case, it looks like there’s enough energy in the first frame (2048 samples) to keep it above the threshold. If you want to narrow the analysis, you can drop the frame length (say, 512) and hop length (say 128) and that should give your expected behavior.@bmcfee Thank you! That worked well. Appreciate your time.