title: putting new wav file on code and synthesize with previous wav file.(python)
body: <p>I'm trying to put new wav. file in code A.</p>
  <p>code A is a code that plays files which Invisible_beauty.wav and thank_you.wav together.
  when code runs, Invisible_beauty.wav file runs first.
  10 sec later, thank_you.wav file runs together.</p>
  <p>and code B, which has problem right now, plays Invisible_beauty.wav and thank_you.wav as same as code A. but I put thanks.wav file.</p>
  <p>thank_you.wav file is only 1 second so I put thanks.wav file at 11sec later from beginning.
  which means there is a 1 sec term between thanks.wav and thank_you.wav</p>
  <p>There is problem I got.</p>
  <blockquote>
  <p><strong>thanks.wav file sound so weird. slow, hear like Darth Vader(I mean sound is so low so I can't understand what it sounds like..)</strong></p>
  </blockquote>
  <p>code runs well. it makes me more complicated. <strong>I want to make thanks.wav file sounds normally.</strong></p>
  <p><strong>code A</strong></p>
  <pre><code># Change the sampling period and channel type of your own sound file
  
  import numpy as np                                        # numpy module for matrix and vector data management 
  
  import matplotlib.pyplot as plt                            # Module for graph representation of sound data 
  
  import scipy.io as sio            
  from scipy.io.wavfile import write                         # Modules for playing wav files as system commands 
  
  import os
  
  # sampling rate
  v_samplerate, v_data = sio.wavfile.read('thank_you.wav')
  b_samplerate, b_data = sio.wavfile.read(&quot;Invisible_Beauty.wav&quot;)
  
  v_times = np.arange(len(v_data))/float(v_samplerate)
  b_times = np.arange(len(b_data))/float(b_samplerate)
  
  # ------------------------------------------------------------------------
  
  # stereo channel -&gt; mono channel
  if (len(v_data.shape) &gt; 1) : 
     v_data = np.array(v_data[:,0])
  if (len(b_data.shape) &gt; 1) : 
     b_data = np.array(b_data[:,0])
  
  # Lower sampling period
  if (v_samplerate &gt; b_samplerate) :
     diffRate = v_samplerate / b_samplerate
     v_data = np.array(v_data[0:len(v_data):diffRate])
     sr = b_samplerate
  elif (v_samplerate &lt; b_samplerate) : 
     diffRate = int(b_samplerate / v_samplerate)
     b_data = np.array(b_data[0:len(b_data):diffRate])
     sr = v_samplerate
  else :
     sr = b_samplerate
  
  # Synthesizing background music and voice data with a 10-second point
  mix_data = v_data + b_data[sr*10:len(v_data)+sr*10]
  
  # Put the synthesized data in the background music 10 seconds position
  
  b_data[sr*10:len(v_data)+sr*10] = mix_data
  
  # Save a composed file as a wav file
  scaled = np.int16(b_data/np.max(np.abs(b_data)) * 32767)
  write('music_card.wav', sr, scaled)
  os.system(&quot;start music_card.wav&quot;)
  
  </code></pre>
  <p><strong>code B</strong></p>
  <pre><code>
  
  # Change the sampling period and channel type of your own sound file
  
  import numpy as np                                         # numpy module for matrix and vector data management 
  import matplotlib.pyplot as plt                            # Module for graph representation of sound data 
  
  import scipy.io as sio            
  from scipy.io.wavfile import write                        # Modules for playing wav files as system commands 
  
  import os
  
  # sampling rate
  v_samplerate, v_data = sio.wavfile.read('thank_you.wav')
  b_samplerate, b_data = sio.wavfile.read(&quot;Invisible_Beauty.wav&quot;)
  c_samplerate, c_data = sio.wavfile.read('thanks1.wav')
  
  v_times = np.arange(len(v_data))/float(v_samplerate)
  b_times = np.arange(len(b_data))/float(b_samplerate)
  c_times = np.arange(len(c_data))/float(c_samplerate)
  
  # ------------------------------------------------------------------------
  
  # stereo channel -&gt; mono channel
  if (len(v_data.shape) &gt; 1) : 
     v_data = np.array(v_data[:,0])
  if (len(b_data.shape) &gt; 1) : 
     b_data = np.array(b_data[:,0])
  if (len(c_data.shape) &gt; 1) : 
     b_data = np.array(c_data[:,0])
  
  # Lower sampling period
  if (v_samplerate &gt; b_samplerate) :
     diffRate = int(v_samplerate / b_samplerate)
     v_data = np.array(v_data[0:len(v_data):diffRate])
     sr = b_samplerate
  elif (v_samplerate &lt; b_samplerate) : 
     diffRate = int(b_samplerate / v_samplerate)
     b_data = np.array(b_data[0:len(b_data):diffRate])
     sr = v_samplerate
  elif (c_samplerate &gt; b_samplerate) :
     diffRate = (c_samplerate / b_samplerate)
     c_data = np.array(c_data[0:len(c_data):diffRate])
     sr = b_samplerate
  elif (c_samplerate &lt; b_samplerate) : 
     diffRate = int(b_samplerate / c_samplerate)
     b_data = np.array(b_data[0:len(b_data):diffRate])
     sr = c_samplerate
  else :
     sr = b_samplerate
  
  # Synthesizing background music and voice data with a 10-second point
  mix_data = v_data + b_data[sr*10:len(v_data)+sr*10]
  mix_data1=c_data + b_data[sr*11:len(c_data)+sr*11]
  
  # Put the synthesized data in the background music 10 seconds position
  
  b_data[sr*10:len(v_data)+sr*10] = mix_data
  b_data[sr*11:len(c_data)+sr*11] = mix_data1
  
  
  # Save a composed file as a wav file
  scaled = np.int16(b_data/np.max(np.abs(b_data)) *32767/2)
  write('music_card.wav', sr, scaled)
  os.system(&quot;start music_card.wav&quot;)
  
  </code></pre>
  <p>really appreciate your answering my question.</p>