Example #1
0
from scipy.io.wavfile import write
import scipy as sp
import pysms

audio_file = "voice.wav"

# analyse audio, also calculate the Discrete Cepstrum Envelope
frames, sms_header, snd_header = \
    pysms.analyze(audio_file, env_type=pysms.SMS_ENV_FBINS, env_order=80)

# Set modification parameters
mod_params = pysms.SMS_ModifyParams()
mod_params.maxFreq = 12000 # only calculate envelope up to 12 kHz
mod_params.doSinEnv = True # apply envelope to sinusoidal component
mod_params.doTranspose = True
mod_params.transpose = 4 # 4 semi-tones up

# apply modification to each frame
for frame in frames:
    pysms.sms_modify(frame, mod_params)

# Synthesis
output = pysms.synthesize(frames, sms_header)

# convert audio to int values
output /= output.max()
output = sp.asarray(output*32768, sp.int16)

# write output files
write("voice_transposed_env.wav", snd_header.iSamplingRate, output)
Example #2
0
mod_params = SMS_ModifyParams()
sms_initModify(source_sms_header, mod_params)
mod_params.doSinEnv = True 
mod_params.sinEnvInterp = envelope_interp_factor

source_env_mags = zeros(mod_params.sizeSinEnv)

for frame_number in range(num_frames):
    source_frame = source_frames[frame_number]
    target_frame = target_frames[frame_number]
    
    # get the source envelope and put in the mod_params
    source_frame.getSinEnv(source_env_mags)
    mod_params.setSinEnv(source_env_mags)
    # call modifications
    sms_modify(target_frame, mod_params)

# change the output number of frames to the minimum of the two frame counts
target_frames = target_frames[0:num_frames]
target_sms_header.nFrames = num_frames

# Synthesis
morph = pysms_synthesize(target_frames, target_sms_header)

# convert audio to int values
morph *= 32767
morph *= 0.25 # soopastar sample clips so make output quieter
morph = asarray(morph, int16)

# write output files
write("modify_example_morph.wav", target_snd_header.iSamplingRate, morph)
Example #3
0
from scipy.io.wavfile import write
import scipy as sp
import pysms

audio_file = "voice.wav"

# analyse audio, also calculate the Discrete Cepstrum Envelope
frames, sms_header, snd_header = \
    pysms.analyze(audio_file, env_type=pysms.SMS_ENV_FBINS, env_order=80)

# Set modification parameters
mod_params = pysms.SMS_ModifyParams()
mod_params.maxFreq = 12000  # only calculate envelope up to 12 kHz
mod_params.doSinEnv = True  # apply envelope to sinusoidal component
mod_params.doTranspose = True
mod_params.transpose = 4  # 4 semi-tones up

# apply modification to each frame
for frame in frames:
    pysms.sms_modify(frame, mod_params)

# Synthesis
output = pysms.synthesize(frames, sms_header)

# convert audio to int values
output /= output.max()
output = sp.asarray(output * 32768, sp.int16)

# write output files
write("voice_transposed_env.wav", snd_header.iSamplingRate, output)
Example #4
0
mod_params = SMS_ModifyParams()
sms_initModify(source_sms_header, mod_params)
mod_params.doSinEnv = True
mod_params.sinEnvInterp = envelope_interp_factor

source_env_mags = zeros(mod_params.sizeSinEnv)

for frame_number in range(num_frames):
    source_frame = source_frames[frame_number]
    target_frame = target_frames[frame_number]

    # get the source envelope and put in the mod_params
    source_frame.getSinEnv(source_env_mags)
    mod_params.setSinEnv(source_env_mags)
    # call modifications
    sms_modify(target_frame, mod_params)

# change the output number of frames to the minimum of the two frame counts
target_frames = target_frames[0:num_frames]
target_sms_header.nFrames = num_frames

# Synthesis
morph = synthesize(target_frames, target_sms_header)

# convert audio to int values
morph *= 32767
morph *= 0.25  # soopastar sample clips so make output quieter
morph = asarray(morph, int16)

# write output files
write("modify_example_morph.wav", target_snd_header.iSamplingRate, morph)