Additional scripts
Notes
Here are some additional functions that I wanted to share.
The results of find_offsets
are cached in cached_offset_searches.pickle
Code
find_offsets(within_file, find_file, multiplier, window=2, number=None, max_tries_number=80, to_print_plots=False)
Finds time codes of appearance audio of find_file in within_file using scipy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
within_file |
str
|
path to the audio file to search within |
required |
find_file |
str
|
path to the audio file to search for |
required |
multiplier |
float
|
a multiplier used to calculate the prominence of peaks in the correlation signal. The bigger you set it, the less time codes function returns. |
required |
window |
int
|
the length of find_file audio to use for the correlation (in seconds) |
2
|
number |
int
|
the goal number of offsets to return |
None
|
max_tries_number |
int
|
maximum number of tries to find the number |
80
|
to_print_plots |
bool
|
whether to print plot before proceeding |
False
|
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of time codes |
Source code in ffmpeg_python_utils\other.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
remove_silence_from_audio_file(input_path, output_path, audio_format='wav', min_silence_len=100, silence_thresh=-45, keep_silence=50)
Removes silence from audio file. Results are cached taking in account hash of the input files and kwargs passed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_path |
str
|
The path to the audio file. |
required |
output_path |
str
|
The path to the directory where the edited audio files will be saved. |
required |
audio_format |
str
|
The format of the audio output. |
'wav'
|
min_silence_len |
int
|
The minimum length of silence to be removed, in milliseconds. |
100
|
silence_thresh |
int
|
The threshold for silence, in decibels. |
-45
|
keep_silence |
int
|
The length of silence to keep at the beginning and end of the audio file, in milliseconds. |
50
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
output_path |
Source code in ffmpeg_python_utils\other.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|