-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an example of phase vocoder based time stretch and pitch shift ca…
…pabilities
- Loading branch information
1 parent
7a9d0c9
commit 26353ac
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import zounds | ||
from zounds.spectral import time_stretch, pitch_shift | ||
from zounds.ui import AppSettings | ||
import argparse | ||
|
||
sr = zounds.SR11025() | ||
BaseModel = zounds.stft(resample_to=sr, store_resampled=True) | ||
|
||
|
||
@zounds.simple_in_memory_settings | ||
class Sound(BaseModel): | ||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(parents=[ | ||
AppSettings() | ||
]) | ||
parser.add_argument( | ||
'--sound-uri', | ||
default='https://archive.org/download/LucaBrasi2/06-Kevin_Gates-Out_The_Mud_Prod_By_The_Runners_The_Monarch.ogg') | ||
args = parser.parse_args() | ||
|
||
_id = Sound.process(meta=args.sound_uri) | ||
snd = Sound(_id) | ||
|
||
original = snd.resampled | ||
slow = zounds.AudioSamples(time_stretch(original, 0.75).squeeze(), sr) | ||
fast = zounds.AudioSamples(time_stretch(original, 1.25).squeeze(), sr) | ||
|
||
higher = zounds.AudioSamples( | ||
pitch_shift(original[:zounds.Seconds(10)], 1.0).squeeze(), sr) | ||
lower = zounds.AudioSamples( | ||
pitch_shift(original[:zounds.Seconds(10)], -1.0).squeeze(), sr) | ||
|
||
app = zounds.ZoundsApp( | ||
model=Sound, | ||
visualization_feature=Sound.fft, | ||
audio_feature=Sound.resampled, | ||
globals=globals(), | ||
locals=locals(), | ||
secret=args.app_secret) | ||
|
||
app.start(args.port) |