[bash] update
This commit is contained in:
1 parent
09a0865c5c
commit
423269f538
4 files changed
+58
-22
No files matched your search
@@ -1,10 +1,14 @@
|
||||
import wave
|
||||
# 读取wave文件,并打印采样率、量化位数、声道数
|
||||
# 读取wave文件,并打印data长度
|
||||
with wave.open('output_1708083097.9604511.wav', 'rb') as f:
|
||||
with wave.open('output.wav', 'rb') as f:
|
||||
data = f.readframes(f.getnframes())
|
||||
print(len(data))
|
||||
print(type(data))
|
||||
nchannels, sampwidth, framerate, nframes, comptype, compname = f.getparams()
|
||||
print(framerate, sampwidth, nchannels)
|
||||
|
||||
print("采样率:", framerate)
|
||||
print("量化位数:", sampwidth)
|
||||
print("声道数:", nchannels)
|
||||
print("data长度:", nframes)
|
||||
print("压缩类型:", comptype)
|
||||
print("压缩名称:", compname)
|
||||
@@ -0,0 +1,13 @@
|
||||
from takway.audio_utils import AudioPlayer
|
||||
|
||||
# RATE = 22050
|
||||
RATE = 16000
|
||||
# device_idx = 3 # 声卡编号,根据实际情况修改
|
||||
device_idx = None # 使用默认声卡
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
audio_player = AudioPlayer(RATE=RATE, output_device_index=device_idx)
|
||||
# frames = audio_player.load_audio_file("my_recording.wav") # wav或pcm格式音频都支持
|
||||
frames = audio_player.load_audio_file("output.wav") # wav或pcm格式音频都支持
|
||||
audio_player.play(frames)
|
||||
Reference in new issue
Block a user