ش | ی | د | س | چ | پ | ج |
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
You can use sounddevice and scipy library to record sound using Python. You can use the following command to install these two libraries:
!pip install sounddevice scipy
Then, using the following commands, you can write a simple program to record audio:
import sounddevice as sd
from scipy.io.wavfile import write
fs = 44100 # نرخ نمونهبرداری
duration = 10 # مدت زمان ضبط صدا (ثانیه)
# ضبط صدا
recording = sd.rec(int(fs * duration), samplerate=fs, channels=1)
# انتظار برای اتمام ضبط صدا
sd.wait()
# ذخیرهی فایل
write("recorded_audio.wav", fs, recording)
import sounddevice as sd
from scipy.io.wavfile import write, read
fs = 44100 # نرخ نمونهبرداری
duration = 10 # مدت زمان ضبط صدا (ثانیه)
# پخش صدا
print("Press any key to start playing audio...")
input()
audio, _ = read("input_audio.wav")
sd.play(audio, fs)
sd.wait()
# ضبط صدا
recording = sd.rec(int(fs * duration), samplerate=fs, channels=1)
# انتظار برای اتمام ضبط صدا
sd.wait()
# ذخیرهی فایل
write("recorded_audio.wav", fs, recording)