-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-sox.py
32 lines (22 loc) · 877 Bytes
/
test-sox.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sox
# create transformer
tfm = sox.Transformer()
# trim the audio between 5 and 10.5 seconds.
tfm.trim(5, 10.5)
# apply compression
tfm.compand()
# apply a fade in and fade out
tfm.fade(fade_in_len=1.0, fade_out_len=0.5)
# create an output file.
tfm.build_file('/Users/angel/Desktop/aeiou.wav', '/Users/angel/Desktop/aeiou2.wav')
# or equivalently using the legacy API
tfm.build('path/to/input_audio.wav', 'path/to/output/audio.aiff')
# get the output in-memory as a numpy array
# by default the sample rate will be the same as the input file
array_out = tfm.build_array(input_filepath='/Users/angel/Desktop/aeiou.wav')
# see the applied effects
tfm.effects_log
###### Simple pitch-shifter to in audio files... ######
pps = sox.Transformer()
pps.pitch(12)
pps.build_file('/Users/angel/Music/Canciones/Todos Ellos.mp3', '/Users/angel/Desktop/aeiou-pitcht.mp3')