since 2010-12-04

PortAudiopython から使う。 ドキュメント

v19 の blocking-mode audio I/O のみサポートしている。

関連 python_wave libopenjtalk

Windows でためす


以下 nvdajp の の一部として書いた。16bit short int 16000Hz mono のバイト列を受け取る。

出力終了の検出がうまくできないので time.sleep している。

def pa_play(data):
	# requires pyaudio (PortAudio wrapper)
	import time
	import pyaudio
	p = pyaudio.PyAudio()
	stream = = p.get_format_from_width(2),
		channels = 1, rate = 16000, output = True)
	size = len(data)
	pos = 0 # byte count
	while pos < size:
		a = stream.get_write_available() * 2
		o = data[pos:pos+a]
		pos += a
	time.sleep(float(size) / 2 / 16000)

Ubuntu 9.04 32bit


$ sudo dpkg -i python-pyaudio_0.2.4-1_i386.deb
Selecting previously deselected package python-pyaudio.
(Reading database ... 441812 files and directories currently installed.)
Unpacking python-pyaudio (from .../python-pyaudio_0.2.4-1_i386.deb) ...
dpkg: dependency problems prevent configuration of python-pyaudio:
 python-pyaudio depends on python-support (>= 0.90.0); however:
  Version of python-support on system is 0.8.7ubuntu4.
dpkg: error processing python-pyaudio (--install):
 dependency problems - leaving unconfigured
Processing triggers for doc-base ...
Processing 1 added doc-base file(s)...
Registering documents with scrollkeeper...
Errors were encountered while processing:


pyaudio.txt · 最終更新: 2010/12/10 20:28 by Takuya Nishimoto Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0