本文整理汇总了Python中mycroft.util.log.LOG.info方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.info方法的具体用法?Python LOG.info怎么用?Python LOG.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mycroft.util.log.LOG
的用法示例。
在下文中一共展示了LOG.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: download
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def download(url, filename):
import shutil
from urllib2 import urlopen
LOG.info('Downloading: ' + url)
req = urlopen(url)
with open(filename, 'wb') as fp:
shutil.copyfileobj(req, fp)
示例2: __init__
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"):
super(PreciseHotword, self).__init__(key_phrase, config, lang)
self.update_freq = 24 # in hours
precise_config = Configuration.get()['precise']
self.dist_url = precise_config['dist_url']
self.models_url = precise_config['models_url']
self.exe_name = 'precise-stream'
ww = Configuration.get()['listener']['wake_word']
model_name = ww.replace(' ', '-') + '.pb'
model_folder = expanduser('~/.mycroft/precise')
if not isdir(model_folder):
mkdir(model_folder)
model_path = join(model_folder, model_name)
exe_file = self.find_download_exe()
LOG.info('Found precise executable: ' + exe_file)
self.update_model(model_name, model_path)
args = [exe_file, model_path, '1024']
self.proc = Popen(args, stdin=PIPE, stdout=PIPE)
self.has_found = False
self.cooldown = 20
t = Thread(target=self.check_stdout)
t.daemon = True
t.start()
示例3: handle_utterance
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def handle_utterance(event):
LOG.info("Utterance: " + str(event['utterances']))
context = {'client_name': 'mycroft_listener'}
if 'ident' in event:
ident = event.pop('ident')
context['ident'] = ident
bus.emit(Message('recognizer_loop:utterance', event, context))
示例4: mute_and_speak
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def mute_and_speak(utterance):
"""
Mute mic and start speaking the utterance using selected tts backend.
Args:
utterance: The sentence to be spoken
"""
global tts_hash
lock.acquire()
# update TTS object if configuration has changed
if tts_hash != hash(str(config.get('tts', ''))):
global tts
# Stop tts playback thread
tts.playback.stop()
tts.playback.join()
# Create new tts instance
tts = TTSFactory.create()
tts.init(ws)
tts_hash = hash(str(config.get('tts', '')))
LOG.info("Speak: " + utterance)
try:
tts.execute(utterance)
finally:
lock.release()
示例5: _play
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def _play(self, message=None):
""" Implementation specific async method to handle playback.
This allows mpg123 service to use the "next method as well
as basic play/stop.
"""
LOG.info('Mpg123Service._play')
self._is_playing = True
track = self.tracks[self.index]
# Replace file:// uri's with normal paths
track = track.replace('file://', '')
self.process = subprocess.Popen(['mpg123', track])
# Wait for completion or stop request
while self.process.poll() is None and not self._stop_signal:
sleep(0.25)
if self._stop_signal:
self.process.terminate()
self.process = None
self._is_playing = False
return
self.index += 1
# if there are more tracks available play next
if self.index < len(self.tracks):
self.emitter.emit(Message('Mpg123ServicePlay'))
else:
self._is_playing = False
示例6: main
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def main():
global ws
global config
ws = WebsocketClient()
Configuration.init(ws)
config = Configuration.get()
speech.init(ws)
# Setup control of pulse audio
setup_pulseaudio_handlers(config.get('Audio').get('pulseaudio'))
def echo(message):
try:
_message = json.loads(message)
if 'mycroft.audio.service' not in _message.get('type'):
return
message = json.dumps(_message)
except:
pass
LOG.debug(message)
LOG.info("Staring Audio Services")
ws.on('message', echo)
ws.once('open', load_services_callback)
try:
ws.run_forever()
except KeyboardInterrupt, e:
LOG.exception(e)
speech.shutdown()
sys.exit()
示例7: during_download
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def during_download(self, first_run=False):
LOG.info('Still downloading executable...')
if first_run: # TODO: Localize
self._snd_msg('mouth.text=Updating listener...')
if not self.download_complete:
self.show_download_progress = Timer(30, self.during_download)
self.show_download_progress.start()
示例8: shutdown
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def shutdown(self):
for s in self.service:
try:
LOG.info('shutting down ' + s.name)
s.shutdown()
except Exception as e:
LOG.error('shutdown of ' + s.name + ' failed: ' + repr(e))
# remove listeners
self.bus.remove('mycroft.audio.service.play', self._play)
self.bus.remove('mycroft.audio.service.queue', self._queue)
self.bus.remove('mycroft.audio.service.pause', self._pause)
self.bus.remove('mycroft.audio.service.resume', self._resume)
self.bus.remove('mycroft.audio.service.stop', self._stop)
self.bus.remove('mycroft.audio.service.next', self._next)
self.bus.remove('mycroft.audio.service.prev', self._prev)
self.bus.remove('mycroft.audio.service.track_info', self._track_info)
self.bus.remove('mycroft.audio.service.seek_forward',
self._seek_forward)
self.bus.remove('mycroft.audio.service.seek_backward',
self._seek_backward)
self.bus.remove('recognizer_loop:audio_output_start',
self._lower_volume)
self.bus.remove('recognizer_loop:record_begin', self._lower_volume)
self.bus.remove('recognizer_loop:audio_output_end',
self._restore_volume)
self.bus.remove('recognizer_loop:record_end', self._restore_volume)
self.bus.remove('mycroft.stop', self._stop)
示例9: supported_uris
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def supported_uris(self):
""" Return supported uris of chromecast. """
LOG.info("Chromecasts found: " + str(self.cast))
if self.cast:
return ['http', 'https']
else:
return []
示例10: load_module
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def load_module(module, hotword, config, lang, loop):
LOG.info('Loading "{}" wake word via {}'.format(hotword, module))
instance = None
complete = Event()
def initialize():
nonlocal instance, complete
try:
clazz = HotWordFactory.CLASSES[module]
instance = clazz(hotword, config, lang=lang)
except TriggerReload:
complete.set()
sleep(0.5)
loop.reload()
except NoModelAvailable:
LOG.warning('Could not found find model for {} on {}.'.format(
hotword, module
))
instance = None
except Exception:
LOG.exception(
'Could not create hotword. Falling back to default.')
instance = None
complete.set()
Thread(target=initialize, daemon=True).start()
if not complete.wait(INIT_TIMEOUT):
LOG.info('{} is taking too long to load'.format(module))
complete.set()
return instance
示例11: mute_and_speak
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def mute_and_speak(utterance, ident):
"""
Mute mic and start speaking the utterance using selected tts backend.
Args:
utterance: The sentence to be spoken
ident: Ident tying the utterance to the source query
"""
global tts_hash
# update TTS object if configuration has changed
if tts_hash != hash(str(config.get('tts', ''))):
global tts
# Stop tts playback thread
tts.playback.stop()
tts.playback.join()
# Create new tts instance
tts = TTSFactory.create()
tts.init(bus)
tts_hash = hash(str(config.get('tts', '')))
LOG.info("Speak: " + utterance)
try:
tts.execute(utterance, ident)
except RemoteTTSTimeoutException as e:
LOG.error(e)
mimic_fallback_tts(utterance, ident)
except Exception as e:
LOG.error('TTS execution failed ({})'.format(repr(e)))
示例12: validate_connection
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def validate_connection(self):
try:
subprocess.call([BIN, '--version'])
except:
LOG.info("Failed to find mimic at: " + BIN)
raise Exception(
'Mimic was not found. Run install-mimic.sh to install it.')
示例13: _do_net_check
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def _do_net_check(self):
# TODO: This should live in the derived Enclosure, e.g. Enclosure_Mark1
LOG.info("Checking internet connection")
if not connected(): # and self.conn_monitor is None:
if has_been_paired():
# TODO: Enclosure/localization
self.ws.emit(Message("speak", {
'utterance': "This unit is not connected to the Internet."
" Either plug in a network cable or hold the "
"button on top for two seconds, then select "
"wifi from the menu"
}))
else:
# Begin the unit startup process, this is the first time it
# is being run with factory defaults.
# TODO: This logic should be in Enclosure_Mark1
# TODO: Enclosure/localization
# Don't listen to mic during this out-of-box experience
self.ws.emit(Message("mycroft.mic.mute"))
# Setup handler to unmute mic at the end of on boarding
# i.e. after pairing is complete
self.ws.once('mycroft.paired', self._handle_pairing_complete)
# Kick off wifi-setup automatically
self.ws.emit(Message("mycroft.wifi.start",
{'msg': "Hello I am Mycroft, your new "
"assistant. To assist you I need to be "
"connected to the internet. You can "
"either plug me in with a network cable,"
" or use wifi. To setup wifi ",
'allow_timeout': False}))
示例14: _do_net_check
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def _do_net_check(self):
# TODO: This should live in the derived Enclosure, e.g. Enclosure_Mark1
LOG.info("Checking internet connection")
if not connected(): # and self.conn_monitor is None:
if has_been_paired():
# TODO: Enclosure/localization
self.speak("This unit is not connected to the Internet. "
"Either plug in a network cable or hold the "
"button on top for two seconds, then select "
"wifi from the menu")
else:
# Begin the unit startup process, this is the first time it
# is being run with factory defaults.
# TODO: This logic should be in Enclosure_Mark1
# TODO: Enclosure/localization
# Don't listen to mic during this out-of-box experience
self.ws.emit(Message("mycroft.mic.mute"))
# Setup handler to unmute mic at the end of on boarding
# i.e. after pairing is complete
self.ws.once('mycroft.paired', self._handle_pairing_complete)
self.speak(mycroft.dialog.get('mycroft.intro'))
wait_while_speaking()
time.sleep(2) # a pause sounds better than just jumping in
# Kick off wifi-setup automatically
data = {'allow_timeout': False, 'lang': self.lang}
self.ws.emit(Message('system.wifi.setup', data))
示例15: transcribe
# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import info [as 别名]
def transcribe(self, audio):
try:
# Invoke the STT engine on the audio clip
text = self.stt.execute(audio).lower().strip()
LOG.debug("STT: " + text)
return text
except sr.RequestError as e:
LOG.error("Could not request Speech Recognition {0}".format(e))
except ConnectionError as e:
LOG.error("Connection Error: {0}".format(e))
self.emitter.emit("recognizer_loop:no_internet")
except HTTPError as e:
if e.response.status_code == 401:
LOG.warning("Access Denied at mycroft.ai")
return "pair my device" # phrase to start the pairing process
else:
LOG.error(e.__class__.__name__ + ': ' + str(e))
except RequestException as e:
LOG.error(e.__class__.__name__ + ': ' + str(e))
except Exception as e:
self.emitter.emit('recognizer_loop:speech.recognition.unknown')
if isinstance(e, IndexError):
LOG.info('no words were transcribed')
else:
LOG.error(e)
LOG.error("Speech Recognition could not understand audio")
return None
if connected():
dialog_name = 'backend.down'
else:
dialog_name = 'not connected to the internet'
self.emitter.emit('speak', {'utterance': dialog.get(dialog_name)})