def decir(texto):
    track = sonos.get_current_track_info()
    playlistPos = int(track['playlist_position'])-1
    trackPos = track['position']
    trackURI = track['uri']

    # This information allows us to resume services like Pandora
    mediaInfo = sonos.avTransport.GetMediaInfo([('InstanceID', 0)])
    mediaURI = mediaInfo['CurrentURI']
    mediaMeta = mediaInfo['CurrentURIMetaData']

    # Play the alert sound, and sleep to allow it to play through
    #print 'Playing alert %s' % alertSoundURL
    #sonos.play_uri(alertSoundURL)
    

    try:
        ok, file_name =  text2mp3(texto, PATH, LANGUAGE, ALERT)

        if ok:
            #zp = SoCo(ip_sonos)
            print('x-file-cifs:%s' % '//homeserver/sonidos/speech.mp3')
            sonos.play_uri('x-file-cifs:%s' % '//homeserver/sonidos/speech.mp3')
            #alertDuration = zp.get_current_track_info()['duration']
            #sleepTime=float(alertDuration)
            #time.sleep(sleepTime)
            #if len(zp.get_queue()) > 0 and playlistPos > 0:
            #    print 'Resume queue from %d: %s - %s' % (playlistPos, track['artist'], track['title'])
            #    zp.play_from_queue(playlistPos)
            #    zp.seek(trackPos)
            #else:
            #    print 'Resuming %s' % mediaURI
             #   zp.play_uri(mediaURI, mediaMeta)
    except:
        print "Error text2speech"
예제 #2
0
파일: server.py 프로젝트: r0stig/say
def say(text):
    ok, file_name =  text2mp3(text, PATH, LANGUAGE)
    if ok:
        zp = SoCo(IP)
        cur_info = zp.get_current_track_info()
        state = zp.get_current_transport_info()
        zp.play_uri("http://{0}:5000/static/speech.mp3".format(LAN_IP))
        if (state['current_transport_state'] == 'PLAYING'):
            audio = MP3("./static/speech.mp3")
            speech_info = zp.get_current_track_info()
            duration = speech_info['duration']
            Timer(audio.info.length, resume_queue, (zp, cur_info)).start()
    return "OK!"
def decir2(texto):
    track = sonos.get_current_track_info()
    playlistPos = int(track['playlist_position'])-1
    trackPos = track['position']
    trackURI = track['uri']

    # This information allows us to resume services like Pandora
    mediaInfo = sonos.avTransport.GetMediaInfo([('InstanceID', 0)])
    mediaURI = mediaInfo['CurrentURI']
    mediaMeta = mediaInfo['CurrentURIMetaData']

    ok, file_name =  text2mp3(texto, PATH, LANGUAGE, False)
    if ok:
        zp = SoCo(ip_sonos)
        print('x-file-cifs:%s' % '//homeserver/sonidos/speech.mp3')
        zp.play_uri('x-file-cifs:%s' % '//homeserver/sonidos/speech.mp3')
예제 #4
0
파일: Test_Voice.py 프로젝트: DPH/say
def main():
    '''
    Test stub to call the say routine.
    Command line provides the words to say in inverted commas
    If omitted then uses a default text
    '''
    #use text argument from command line if present - else use default
    if len(sys.argv) < 2:
        txt = DEFUALT_TEXT
    else:
        txt = sys.argv[1]
    
    print ('Testing using %s character string "%s"' %  (len(txt), txt) )
    ok, file_name =  text2mp3(txt, PATH, LANGUAGE, ALERT)
    
    #if TTS worked OK, use file name returned to play MP3 on Sonos
    if ok:
        zp = SoCo(IP)
        zp.play_uri('x-file-cifs:%s' % file_name)
        print 'Listen to your Sonos - check volume turned up!'
예제 #5
0
def get_speech_uri(text):
	ok, file_name = text2mp3(text, speech_local_dir, speech_language)
	if ok:
		return speech_ext_path + speech_file