Merge branch 'master' of gitlab.com:hugvey/hugvey

This commit is contained in:
Ruben van de Ven 2019-01-30 18:00:57 +01:00
commit da6c13ef1f

View file

@ -7,10 +7,14 @@ import socket
import threading import threading
import time import time
import yaml import yaml
import alsaaudio
import zmq import zmq
from zmq.asyncio import Context from zmq.asyncio import Context
try:
import alsaaudio
except ImportError:
print("No volume settings available")
from .communication import zmqReceive, zmqSend, getTopic from .communication import zmqReceive, zmqSend, getTopic
import subprocess import subprocess
@ -246,8 +250,14 @@ class Hugvey(object):
def getId(self) -> int: def getId(self) -> int:
"""Get Hugvey ID from hostname""" """Get Hugvey ID from hostname"""
try:
h = socket.gethostname() h = socket.gethostname()
return int(re.findall('\d+', h )[0]) id = int(re.findall('\d+', h )[0])
except Exception:
logger.critical("No automatic ID, fall back to 1")
id = 1
return id
def loadConfig(self, filename): def loadConfig(self, filename):
with open(filename, 'r') as fp: with open(filename, 'r') as fp:
@ -260,7 +270,7 @@ class Hugvey(object):
def start(self): def start(self):
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
if self.config['voice']['play_device']: if self.config['voice']['play_device'] and 'alsaaudio' in sys.modules:
alsaaudio.Mixer(self.config['voice']['play_device']).setvolume(self.config['voice']['play_volume']) alsaaudio.Mixer(self.config['voice']['play_device']).setvolume(self.config['voice']['play_volume'])
self.voice_server = VoiceServer( self.voice_server = VoiceServer(