python 录音,WAV转MP3
2019-08-29 python 2023
录音功能 ,只录音系统的声音
import sounddevice as sd from scipy.io import wavfile # fs = 44100 # Hz # length = 15 # s recording = sd.rec(frames=fs * length, samplerate=fs, blocking=True, channels=1) wavfile.write(file, fs, recording)
WAV转MP3 需要安装ffmpeg
from pydub import AudioSegment import os os.environ["PATH"] = os.environ["PATH"] + ";" + os.path.dirname(os.path.realpath(__file__)) #修改系统临时变量,把ffmpeg带回家 file = r'C:/Users/Administrator/Desktop/system1.wav' song = AudioSegment.from_wav(file) mp3file = os.path.splitext(file)[0] + ".mp3" print(mp3file) song.export(mp3file, format="mp3", bitrate="192k")
很赞哦! (0)
相关文章
文章评论
-
-
-
0条评论