本文整理匯總了Python中recorder.Recorder.open方法的典型用法代碼示例。如果您正苦於以下問題:Python Recorder.open方法的具體用法?Python Recorder.open怎麽用?Python Recorder.open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類recorder.Recorder
的用法示例。
在下文中一共展示了Recorder.open方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ButtonRecorder
# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import open [as 別名]
class ButtonRecorder(object):
def __init__(self, filename):
self.filename = filename
gpio.setup(23, gpio.IN, pull_up_down=gpio.PUD_UP)
self.rec = Recorder(channels=2)
def start(self):
gpio.add_event_detect(23, gpio.FALLING, callback=self.falling, bouncetime=10)
def rising(self, channel):
gpio.remove_event_detect(23)
print 'Button up'
gpio.add_event_detect(23, gpio.FALLING, callback=self.falling, bouncetime=10)
#TODO: dim red LED
self.recfile.stop_recording()
self.recfile.close()
def falling(self, channel):
ts = time.time()
gpio.remove_event_detect(23)
print 'Button down'
gpio.add_event_detect(23, gpio.RISING, callback=self.rising, bouncetime=10)
#TODO: lit green LED
play = PlayFile(vloeken.keys()[random.randint(0,len(vloeken))])
play.start()
#TODO: dim green, lite red LED
vloeken[self.filename + str(ts) + '.wav'] = {'inputfor':[]}
with open('vloeken.log', 'wb') as handle:
pickle.dump(vloeken, handle)
self.recfile = self.rec.open(self.filename + str(ts) + '.wav', 'wb')
self.recfile.start_recording()
示例2:
# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import open [as 別名]
print 'IDLE=> RSSI: {}'.format(rssi)
if rssi > RSSI_THRESHOLD : # Squelch open
state = 'START_TIMER'
startTimer = START_TIME
elif state == 'START_TIMER' :
print 'START_TIMER=> Start Timer: {} RSSI: {}'.format(startTimer, rssi)
if rssi <= RSSI_THRESHOLD : # Squelch closed
state = 'IDLE'
else :
if startTimer < 1 :
#Start recording
state = 'RECORDING'
#record_to_file('%s%s_%s' % (FILEPATH,datetime.now().strftime(DATE_FORMAT),FILENAME))
recFileName = '%s%s_%s' % (FILEPATH,datetime.now().strftime(DATE_FORMAT),FILENAME)
recFile = rec.open(recFileName, 'wb')
recFile.start_recording()
recordingFlag = 1
timeCounter = 0
else :
startTimer -= 1
elif state == 'RECORDING' :
print 'RECORDING=> TimeCounter: {} RSSI: {}'.format(timeCounter,rssi)
timeCounter += 1
if rssi <= RSSI_THRESHOLD: # Squelch closed
stopTimer = STOP_TIME
state = 'STOP_TIMER'
if timeCounter > MAX_SAMPLE_TIMER: # we only want a sample
recFile.stop_recording()
recordingFlag = 0
示例3: Recorder
# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import open [as 別名]
if "signalclass" in arguments:
if arguments["signalclass"] == "mode":
signalClass = modeActivationValue
elif arguments["signalclass"] == "avg":
signalClass = avgActivationValue
else:
signalClass = DEFAULT_SIGNAL_CLASS
if "signalcount" in arguments:
signalCount = arguments["signalcount"]
else:
signalCount = DEFAULT_SIGNAL_COUNT
wav_file_name = 'sample.wav'
rec = Recorder(channels=2)
print '===================================='
print '********** Start Recording'
print '********** Recording . . .'
with rec.open(wav_file_name, 'wb') as recordfile:
recordfile.record(duration=record_duration)
print '===================================='
print '********** Stop Recording'
print '===================================='
print '********** Voice Signal Results:'
mfcc_file = createMFCC(wav_file_name)
classification,activationValue = classifyUnlabeledSample(mfcc_file,network,signalClass,network.signalLength,signalCount)
certainty = getCertaintyMessage(activationValue)
print 'According to your voice, %s you are a %s!' %(certainty,getGender(activationValue))