当前位置: 首页>>代码示例>>Python>>正文


Python pyaudio.get_sample_size方法代码示例

本文整理汇总了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 
开发者ID:batikim09,项目名称:LIVE_SER,代码行数:25,代码来源:offline_ser.py

示例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) 
开发者ID:magenta,项目名称:magenta,代码行数:4,代码来源:audio_recorder.py

示例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 
开发者ID:DelightRun,项目名称:PyBaiduYuyin,代码行数:16,代码来源:__init__.py


注:本文中的pyaudio.get_sample_size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。