End sem 7; week 2 winter session 2025
This commit is contained in:
20
7th-Semester-Fall-2024/ECOMMS/final-project/sd_test.py
Normal file
20
7th-Semester-Fall-2024/ECOMMS/final-project/sd_test.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import numpy as np
|
||||
import sounddevice as sd
|
||||
import scipy as sp
|
||||
from scipy.io import wavfile
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
sample_rate, wav_data = wavfile.read("fm.wav")
|
||||
time = len(wav_data)/sample_rate
|
||||
|
||||
new_sample_rate = 48E3
|
||||
num_samples = int(time*new_sample_rate)
|
||||
plt.subplot(211)
|
||||
plt.plot(wav_data)
|
||||
wav_data = sp.signal.resample(wav_data, num_samples)
|
||||
plt.subplot(212)
|
||||
plt.plot(wav_data)
|
||||
plt.show()
|
||||
|
||||
sd.play(wav_data, samplerate=new_sample_rate)
|
||||
sd.wait()
|
||||
Reference in New Issue
Block a user