示例#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)
示例#2
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)
示例#3
0
# Copyright (c) 2010 John Glover, National University of Ireland, Maynooth
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
from scipy.io.wavfile import write
import numpy as np
import pysms

# Simple synthesis by analysis using libsms
input_file = 'flute.wav'
analysis_data, sms_header, snd_header = pysms.analyze(input_file)
audio_out = pysms.synthesize(analysis_data, sms_header)
write("synth.wav", sms_header.iSamplingRate,
      np.asarray(audio_out * 32768, dtype=np.int16))
示例#4
0
# Copyright (c) 2010 John Glover, National University of Ireland, Maynooth
#  
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
from scipy.io.wavfile import write
import numpy as np
import pysms

# Simple synthesis by analysis using libsms
input_file = 'flute.wav'
analysis_data, sms_header, snd_header = pysms.analyze(input_file)
audio_out = pysms.synthesize(analysis_data, sms_header)
write("synth.wav", sms_header.iSamplingRate, np.asarray(audio_out*32768, dtype=np.int16))

示例#5
0
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)
print "wrote modify_example_morph.wav"

# ----------------------------------------------------------------------------------------
# Transpose without maintaining envelope

# Set modification parameters
mod_params = SMS_ModifyParams()
示例#6
0
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)
print "wrote modify_example_morph.wav"

# ----------------------------------------------------------------------------------------
# Transpose without maintaining envelope  

# Set modification parameters
mod_params = SMS_ModifyParams()