9

使用 pyaudio 播放音乐时碰到的一些奇奇怪怪的问题

 3 years ago
source link: https://www.v2ex.com/t/802987
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Python

使用 pyaudio 播放音乐时碰到的一些奇奇怪怪的问题

  MiketsuSmasher · 2 小时 25 分钟前 · 73 次点击
from pydub import AudioSegment
from pyaudio import PyAudio

segment = AudioSegment.from_file('test.flac')

PAIMON = PyAudio()

stream = PAIMON.open(format=PAIMON.get_format_from_width(segment.sample_width), channels=segment.channels, rate=segment.frame_rate, output=True)

for frame_index in range(int(segment.frame_count())):
    stream.write(segment.get_frame(frame_index))

发现一些奇怪的问题:

  1. 播放时会间歇性的出现一些间隔极小的中断
  2. 24-bit ( pcm_s32le )的音频文件在播放时会有极为吵闹的杂音

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK