本文整理汇总了Python中pyaudio.get_sample_size方法的典型用法代码示例。如果您正苦于以下问题:Python pyaudio.get_sample_size方法的具体用法?Python pyaudio.get_sample_size怎么用?Python pyaudio.get_sample_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaudio
的用法示例。
在下文中一共展示了pyaudio.get_sample_size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: predict_file
# 需要导入模块: import pyaudio [as 别名]
# 或者: from pyaudio import get_sample_size [as 别名]
def predict_file(dec, pyaudio, path, frames, args, rate = 16000, format = pyaudio.paInt16, save = False):
wf = wave.open(path, 'wb')
wf.setnchannels(1)
wf.setsampwidth(pyaudio.get_sample_size(format))
wf.setframerate(rate)
#this code works for only for pulseaudio
#wf.writeframes(b''.join(frames))
wf.writeframes(frames)
wf.close()
results = dec.predict_file(path, feat_mode = args.feat_mode, feat_dim = args.feat_dim, three_d = args.three_d)
if save == False:
os.remove(path)
if args.predict_mode == 0:
task_outputs = dec.returnDiff(results)
elif args.predict_mode == 1:
task_outputs = dec.returnLabel(results)
else:
task_outputs = dec.returnClassDist(results)
return task_outputs
#main loop for speech emotion recognition
示例2: bytes_per_sample
# 需要导入模块: import pyaudio [as 别名]
# 或者: from pyaudio import get_sample_size [as 别名]
def bytes_per_sample(self):
return pyaudio.get_sample_size(self.pyaudio_format)
示例3: __init__
# 需要导入模块: import pyaudio [as 别名]
# 或者: from pyaudio import get_sample_size [as 别名]
def __init__(self, device_index = None):
assert device_index is None or isinstance(device_index, int), "Device index must be None or an integer"
if device_index is not None: # ensure device index is in range
audio = pyaudio.PyAudio(); count = audio.get_device_count(); audio.terminate() # obtain device count
assert 0 <= device_index < count, "Device index out of range"
self.device_index = device_index
self.format = pyaudio.paInt16 # 16-bit int sampling
self.SAMPLE_WIDTH = pyaudio.get_sample_size(self.format)
self.RATE = 16000 # sampling rate in Hertz
self.CHANNELS = 1 # mono audio
self.CHUNK = 1024 # number of frames stored in each buffer
self.audio = None
self.stream = None