예제 #1
0
 def __init__(self,watchdog):
   super(phraseThread,self).__init__()
   self.name = "phraseThread"
   print("starting: %s"%self.name)
   self.watchdog = watchdog
   self.watchdog.add(self)
   self.hasDisplay = host.getLocalAttr("hasDisplay")
   self.displayType = host.getLocalAttr("displayType")
   self.hasVoice = host.getLocalAttr("hasVoice")
예제 #2
0
def makeSpeakFile(line, language=''):
    rval = None
    if language == '':
        language = 'en-us'
    if debug:
        syslog.syslog("make speak file:" + line + " lang:" + str(language))
    fnameRoot = ""
    try:
        if host.getLocalAttr('hasAudio') is False:
            #if debug: syslog.syslog("speak: no audio");
            return rval
        fnameRoot = "../tmp/" + re.sub('\W+', '_', line)
        if config.internetOn() and language != "es":
            if debug: syslog.syslog("speak: internet on using gTTS")
            if debug: syslog.syslog("playText line:" + line)
            fname = fnameRoot + ".mp3"
            #if debug: syslog.syslog("speak:"+fname)
            tts1 = gTTS(text=line, lang=language)
            tts1.save(fname)
            #if debug: syslog.syslog("speak:"+fname)
            sound = AudioSegment.from_mp3(fname)
            os.unlink(fname)
            fname = fnameRoot + ".wav"
            #if debug: syslog.syslog("speak:"+fname)
            sound.export(fname, format="wav")
            rval = fname
        else:
            rval = doEspeak(fnameRoot, line)
    except Exception as e:
        syslog.syslog("speak error: " + str(e))
        rval = doEspeak(fnameRoot, line)
    convertSampleRate(rval)
    return rval
예제 #3
0
 def setPlayMode(self, cmd):
     rval = jsonStatus("not_master")
     isMasterFlag = host.getLocalAttr('isMaster')
     if debug: syslog.syslog("isMaster: %s" % (isMasterFlag))
     if garden.isMasterFlag:
         player.enable(cmd['cmd'] == "Auto")
         rval = jsonStatus("ok")
     return rval
예제 #4
0
def setup():
    global screen
    global setupDone
    global myFont
    if setupDone:
        return
    pygame.init()
    pygame.mouse.set_visible(False)
    fontSize = host.getLocalAttr('fontSize')
    fontFile = config.specs['fontFile']
    print("seting font to %s %d" % (fontFile, fontSize))
    myFont = pygame.font.Font(
        "%s/%s/%s" % (home, config.specs['fontDir'], fontFile), fontSize)
    if host.getLocalAttr("isRaspberry"):
        screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
    else:
        screen = pygame.display.set_mode([800, 480])
    setupDone = True
    print("display image setup done")
예제 #5
0
    def doProbe(self, cmd):
        state = {}
        state['status'] = "ok"
        state['vol'] = asoundConfig.getVolume()
        isMasterFlag = host.getLocalAttr('isMaster')
        if debug: syslog.syslog("isMaster: %s" % (isMasterFlag))
        state['isMaster'] = isMasterFlag
        state['sound'] = gardenTrack.getCurrentSound()
        phrase = ""
        phraseArg = gardenSpeak.getCurrentPhrase()
        if 'phrase' in phraseArg:
            phrase = phraseArg['phrase']
            phrase = phrase.replace("-", " ")
        state['phrase'] = phrase
        state['phraseScatter'] = False
        state['threads'] = len(gardenTrack.eventThreads)
        state['speaker'] = asoundConfig.getHw()['SpeakerBrand']
        state['auto'] = player.isEnabled()
        isMasterFlag = host.getLocalAttr('isMaster')
        if debug: syslog.syslog("isMaster: %s" % (isMasterFlag))
        if isMasterFlag:
            state['collection'] = soundFile.getCurrentCollection()['desc']
            state['maxEvents'] = soundFile.maxEvents
        else:
            state['collection'] = ""
            state['maxEvents'] = 0
        state['soundMaxVolume'] = gardenTrack.soundMaxVolume

        for k in config.specs.keys():
            if k == 'soundMaxVol':
                continue
            if k == "hosts":
                for h in config.specs[k]:
                    if host.isLocalHost(h['ip']):
                        for hk in h.keys():
                            if hk == 'ip':
                                continue
                            state[hk] = h[hk]
            else:
                state[k] = config.specs[k]
        rval = json.dumps(state)
        if debug: syslog.syslog("Probe:" + rval)
        return rval
예제 #6
0
def doProbe(args):
  state = {}
  state['status'] = "ok"
  state['displayType'] = host.getLocalAttr('displayType')
  state['displayId'] = DisplayHandler.currentId
  state['isMaster']=False
  if host.getLocalAttr('isMaster'):
    state['isMaster'] = True
    state['searchType'] = Master.searchType
  state['isRaspberry'] = host.getLocalAttr('isRaspberry')
  state['hasDisplay'] = host.getLocalAttr('hasDisplay')
  state['wantsPhrase'] = host.getLocalAttr('wantsPhrase')
  state['hasVoice'] = host.getLocalAttr('hasVoice')
  state['hasMusic'] = host.getLocalAttr('hasMusic')
  state['hasPowerCheck'] = host.getLocalAttr('hasPowerCheck')
  return json.dumps(state)
예제 #7
0
파일: iAltar.py 프로젝트: sibosop/iAltar
                            type=str,
                            default=[config.defaultSpecPath],
                            help='specify different config file')
        args = parser.parse_args()
        if debug: print("config path" + args.config[0])
        config.load(args.config[0])
        wd = watchdog.WatchdogThread()
        wd.setDaemon(True)
        wd.start()
        host.setHostPort(config.specs['iAltarServerPort'])
        server.cmdHandler = CmdHandler.handleCmd
        print "%s starting Server Thread" % pname
        sst = server.serverThread(config.specs['iAltarServerPort'])
        sst.setDaemon(True)
        sst.start()
        hasDisplay = host.getLocalAttr('hasDisplay')
        wantsPhrase = host.getLocalAttr('wantsPhrase')
        hasVoice = host.getLocalAttr('hasVoice')
        if hasDisplay:
            dtype = host.getLocalAttr('displayType')
            if dtype == 'Image':
                print "%s starting Display" % pname
                displayImage.setup()
                displayThread = DisplayHandler.displayThread(wd)
                displayThread.setDaemon(True)
                displayThread.start()

            if dtype == 'Phrase':
                print "%s starting Phrase" % pname
                displayImage.setup()
예제 #8
0
파일: garden.py 프로젝트: sibosop/netGarden
                         help='set debug')
     parser.add_argument('-c',
                         '--config',
                         nargs=1,
                         type=str,
                         default=[config.defaultSpecPath],
                         help='specify different config file')
     args = parser.parse_args()
     if debug: syslog.syslog("config path" + args.config[0])
     config.load(args.config[0])
 except Exception, e:
     syslog.syslog("config error:" + str(e))
     exit(5)
 if "masterVolume" in config.specs:
     setVolume(config.specs['masterVolume'])
 isMasterFlag = host.getLocalAttr('isMaster')
 if debug: syslog.syslog("isMaster: %s" % (isMasterFlag))
 sst = soundServer.soundServerThread(8080)
 sst.setDaemon(True)
 sst.start()
 soundTrack.setup()
 gardenTrack.changeNumGardenThreads(numGardenThreads)
 speakThread = gardenSpeak.gardenSpeakThread()
 speakThread.setDaemon(True)
 speakThread.start()
 if isMasterFlag:
     syslog.syslog("starting player")
     pt = player.playerThread()
     pt.setDaemon(True)
     pt.start()
 while gardenExit == 0: