コード例 #1
0
    def __init__(self, file_path):

        self.file_path = file_path
        self.fd = open(file_path)
        if self.is_id3():
            self.parser_mp3()
            self.seconds = mp3play.load(self.file_path).seconds()
        else:
            self.seconds = mp3play.load(self.file_path).seconds()
コード例 #2
0
 def run(self):
     global T
     n = netease()
     mp3 = None
     list = None
     while True:
         tmp = q.get()
         str_tmp = str(tmp[0]).lower()
         if str_tmp == 'exit':
             break
         if str_tmp == 'next':
             try:
                 mp3.stop()
                 T.cancel()
             except:
                 pass
             list = n.fm()
             print list
             url = n.id_to_url(list[0])
             print url
             req = n.like(list[0])
             print(req)
             mp3=mp3play.load(url)
             mp3.play()
             T = Timer(mp3.seconds(), func)
             T.start()
         if str_tmp == 'trash':
             try:
                 mp3.stop()
                 T.cancel()
             except:
                 pass
             req = n.trash(list[0])
             print(req)
             req = n.like(songid=list[0], like=False)
             print(req)
             list = n.fm()
             print(list)
             url = n.id_to_url(list[0])
             print(url)
             req = n.like(list[0])
             print(req)
             mp3 = mp3play.load(url)
             mp3.play()
             T = Timer(mp3.seconds(), func)
             T.start()
         if str_tmp == 'login':
             n.login(tmp[1], tmp[2], tmp[3])
         if str_tmp == 'stop':
             try:
                 mp3.stop()
                 T.cancel()
             except:
                 pass
コード例 #3
0
ファイル: feedback.py プロジェクト: flowsha/zhwh
 def __init__(self):
     self.uid = ""
     self.passwd = ""
     self.host = "134.176.102.11"
     self.interval = 60
     self.relogin = 0
     self.hour = [22, 23, 0, 1, 2, 3, 4, 5]
     self.minute = range(51, 56)
     self.alarm_network = mp3play.load("alarm_network.wma")
     self.alarm_bill = mp3play.load("alarm_bill.wma")
     self.alarm_get = mp3play.load("alarm_get.wma")
     self.keys = ["Çë¸÷±¾µØÍø·Ö¹«Ë¾", "Öµ°à¶½¼ì", "»ú·¿¶½¼ì", "¶½¼ì", "Öµ°à", "Ô¤¾¯ÕÏ°­"]
     self.members = ["ÎâÎÀ¶«", "ÁõÎÄÎä", "Òü½¨À¤", "Ф½¨"]
コード例 #4
0
def play():
    time.sleep(0.5)
    mp3 = mp3play.load('data.mp3')
    mp3.play()
    time.sleep(mp3.seconds())
    mp3.stop()
    mp3 = ""
コード例 #5
0
ファイル: playmp3.py プロジェクト: fancyChuan/improve
def usingMp3Play(filepath): # 播放不了,报:指定的设备未打开,或不被 MCI 所识别的错误
    clip = mp3play.load(filepath)
    clip.play()
    duration = clip.milliseconds()  # 返回mp3文件共多少毫秒,注意这里的单位是毫秒

    time.sleep(duration)  # 现在就可以在后台播放完整的mp3了
    clip.stop()
コード例 #6
0
def date():
    text=list(time.ctime().split(' '))
    day_s=['Mon','Tue','Wed','Thur','Fri','Sat','Sun'];
    day=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
    month_s=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
    month=['January','February','March','April','May','June','July','August','September','Octber','November','December']
    year=text[4]
    date=text[2]
    ti=list(text[3].split(':'))
    #print time[0],time[1],time[2]
    hh=ti[0]
    mm=ti[1]
    ss=ti[2]
    #if hh >12 and hh!=24:
    #    hh=int(hh)-12
    #    print hh,":",mm," pm"
    #elif hh==24:
    #        print "00:",mm," am"
    #else:
    #    print hh,":",mm," am"
    #print text
    mon=month[month_s.index(text[1])]
    print date, mon,year
    t=date+" "+mon+" "+year
    tts = gTTS(text=t, lang='en')
    tts.save("date.mp3")
    f="date.mp3"
    audio = MP3(f)
    length=audio.info.length
    clip = mp3play.load(f)
    clip.play()
    time.sleep(length)
    clip.stop()
コード例 #7
0
ファイル: server.py プロジェクト: EPAlan/entry-music-facts
def playSong(filename):
    print 'Playing song %s' % (filename)    
    clip = mp3play.load(path.join('songs', filename))
    clip.play()

    time.sleep(clip.seconds())
    clip.stop()
コード例 #8
0
ファイル: main.py プロジェクト: twitchat/Kalpha
def googletalk(lan, msg):
    if lan == "tw":
        try:
            tts = gTTS(text=msg, lang="zh-tw")            
            tts.save("message.mp3")
        except:
            return 0
    if lan == "en":
        try:
            tts = gTTS(text=msg, lang="en")            
            tts.save("message.mp3")
        except:
            print "en error"
            return 0
    if lan == "jp":
        try:
            tts = gTTS(text=msg, lang="ja")            
            tts.save("message.mp3")
        except:
            print "en error"
            return 0
    filename = "message.mp3"
    clip = mp3play.load(filename)
    
    clip.play()
    time.sleep(min(15, clip.seconds()))
    clip.stop()
コード例 #9
0
def play_music(event):
    index = listbox.curselection()[0]
    music_url = music_list[index]
    urllib.urlretrieve(music_url, '1.mp3')
    mp3 = mp3play.load('1.mp3')
    mp3.play()
    time.sleep(mp3.seconds())  # 设置播放时间
コード例 #10
0
ファイル: init.py プロジェクト: xiaocaiyidie/weiClient
def initProperty():
    manifest = json.load(file('./view/app.json'))
    app.AppTitle = manifest['name'] if manifest['name'] else app.AppTitle
    app.AppUser = manifest['user'] if manifest['user'] else app.AppUser
    app.Debug = manifest['debug'] if manifest['debug'] else app.Debug
    app.HomeDir = getcwd()
    app.Template = manifest['win'] if manifest['win'] else app.Template
    app.App = manifest['app'] if manifest['app'] else app.App
    app.ViewDir = app.HomeDir+'/view/'+app.Template+'/'
    app.AppDir  = app.HomeDir+'/view/'+app.App+'/'
    app.AppIcon = QIcon(app.ViewDir + (manifest['ico'] if manifest['ico'] else app.AppIcon))
    #主页面配置
    app.MainSrc = manifest['main']['url'] if manifest['main']['url'] else app.MainSrc
    app.WinWidth = manifest['main']['width'] if manifest['main']['width'] else app.WinWidth
    app.WinHeight = manifest['main']['height'] if manifest['main']['height'] else app.WinHeight
    app.Opacity = manifest['opacity'] if manifest['opacity'] else app.Opacity
    #对话框配置
    app.DialogSrc = manifest['dialog']['url'] if manifest['dialog']['url'] else app.DialogSrc
    app.DialogCon = manifest['dialog']['content'] if manifest['dialog']['content'] else app.DialogCon
    app.DialogWidth = manifest['dialog']['width'] if manifest['dialog']['width'] else app.DialogWidth
    app.DialogHeight = manifest['dialog']['height'] if manifest['dialog']['height'] else app.DialogHeight
    app.DialogOpacity = manifest['dialog']['opacity'] if manifest['dialog']['opacity'] else app.DialogOpacity

    app.Music = mp3play.load('./view/winView/assets/notify.mp3')

    # 各类初始化
    app._notifications_ = NotificationPresenter()
    app.CookieJar = QNetworkCookieJar()
    app.MainWin = Window(app.MainSrc, app.WinWidth, app.WinHeight)  # 打开窗口
    app._tool_ = toolKit.ToolKit(app.MainWin)
    app._robots_ = robots()
コード例 #11
0
def time_disp():
    text=list(time.ctime().split(' '))
    day_s=['Mon','Tue','Wed','Thur','Fri','Sat','Sun'];
    day=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
    month_s=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
    month=['January','February','March','April','May','June','July','August','September','Octber','November','December']
    year=text[4]
    date=text[2]
    ti=list(text[3].split(':'))
    #print time[0],time[1],time[2]
    hh=ti[0]
    mm=ti[1]
    ss=ti[2]
    tim=""
    if hh >12 and hh!=24:
        hh=int(hh)-12
        hh=str(hh)
        tim=hh+":"+mm+" pm"
    elif hh==24:
        tim="00:"+mm+" am"
    else:
        tim=hh+":"+mm+" am"
    #print text
    print tim
    tim="The Time is "+tim
    tts = gTTS(text=tim, lang='en')
    tts.save("time.mp3")
    f="time.mp3"
    audio = MP3(f)
    length=audio.info.length
    clip = mp3play.load(f)
    clip.play()
    time.sleep(length)
    clip.stop()
コード例 #12
0
ファイル: Runsingle.py プロジェクト: qsq522439539/Autotest
 def _playmp3(self, mfile):
     clip = mp3play.load(mfile)
     clip.play()
     self.logger.info("Play music")
     time.sleep(min(30, clip.seconds()))
     clip.stop()
     return
コード例 #13
0
def rest():
    tts = gTTS(text="If you need me, I'll be around", lang='en')
    tts.save("rest.mp3")
    f="rest.mp3"
    audio = MP3(f)
    length=audio.info.length
    clip = mp3play.load(f)
    clip.play()
    time.sleep(length)
    clip.stop()
    
    with sr.Microphone(device_index = device_id, sample_rate = sample_rate, 
                            chunk_size = chunk_size) as source:
        while True:
            try:
                r.adjust_for_ambient_noise(source)
                print "In silent Mode..."
        
                audio = r.listen(source)
                text = r.recognize_google(audio)
                if text=="wake up jarvis":
                    break
                else:
                    pass
            except:
                pass
コード例 #14
0
ファイル: xiaoyPhoto.py プロジェクト: sunluchang/xiaoyPhoto
 def music(self):
     import mp3play
     filename = u'../music/open.wav'
     mp3 = mp3play.load(filename)
     mp3.play()
     time.sleep(3)
     mp3.stop()
コード例 #15
0
def sleep():
    with mic as source:
        r.adjust_for_ambient_noise(source)
        print("Sleeping..")
        audio = r.listen(source)

    try:
        text = r.recognize_google(audio)
        print(text)
        input = list(text.split(' '))
        if text.lower() == 'wake up friday':
            r1 = random.randint(1, 10000000)
            r2 = random.randint(1, 10000000)
            randfile = "audio\\" + str(r2) + "" + str(r1) + ".mp3"
            print("You: ", input)
            print("Friday: Awake!")
            tts = gTTS(text="I\'m now Listening!", lang='en')
            tts.save(randfile)
            audio = MP3(randfile)
            length = audio.info.length
            clip = mp3play.load(randfile)
            clip.play()
            time.sleep(length)
            clip.stop()
            os.remove(randfile)
            listener(0)
    except sr.UnknownValueError:
        # print("Google Speech Recognition could not understand audio")
        sleep()
    except sr.RequestError as e:
        # print("Could not request results from Google Speech Recognition service; {0}".format(e))
        sleep()
    sleep()
コード例 #16
0
ファイル: Natalie.py プロジェクト: gnzrealm/NatalieDAA
def speak():
    print "Speaking at you..."
    mp3 = mp3play.load('morning.mp3')
    mp3.play()
    while mp3.isplaying():
        sleep(1)
    os.remove('morning.mp3')
コード例 #17
0
ファイル: get_result.py プロジェクト: StormGuoson/GetResult
 def play_query(query):
     if STOP_ALL:
         return
     p = mp3play.load(query)
     p.play()
     time.sleep(p.seconds() + .1)
     while not all_recognized:
         continue
コード例 #18
0
def play(event): 
    sy = listbox.curselection()[0]
    url = data[sy]['audio']
    urllib.urlretrieve(url,'music.mp3')
    mp3 = mp3play.load('music.mp3')
    mp3.play()
    mp3.seconds(time.sleep(mp3.seconds()))
    mp3.stop()
コード例 #19
0
ファイル: pi.py プロジェクト: hoominchu/pi
def playBeep():
    #print('playBeep\n')
    audiofilename = r'C:\Users\hoominchu\Desktop\pi\beep.mp3'
    clip = mp3play.load(audiofilename)

    clip.play()
    time.sleep(1)
    clip.stop()
コード例 #20
0
def play(event):
    sy = listbox.curselection()[0]
    url = data[sy]['audio']
    urllib.urlretrieve(url, 'music.mp3')
    mp3 = mp3play.load('music.mp3')
    mp3.play()
    mp3.seconds(time.sleep(mp3.seconds()))
    mp3.stop()
コード例 #21
0
ファイル: pi.py プロジェクト: urvinsoneta/pi
def playBeep():
    #print('playBeep\n')
    audiofilename = r'C:\Users\hoominchu\Desktop\pi\beep.mp3'
    clip = mp3play.load(audiofilename)

    clip.play()
    time.sleep(1)
    clip.stop()
コード例 #22
0
ファイル: qtplayer.py プロジェクト: bravesnow/xplayer
 def onplay(self):      
     cur=self.list.currentItem()#取得列表框当前项
     if not cur:
         QtGui.QMessageBox.information(self,"Info",u"请选择一个文件名!")
     else:
         self.mp3file=cur.text()#列表框项转成字符串文本
         self.mp3=mp3play.load(self.mp3file)#载入mp3文件
         self.mp3.play()#mp3播放
コード例 #23
0
ファイル: PlayAudio.py プロジェクト: Ianutil/MachineBox
def playMp3(file):

    media = mp3play.load(file)
    media.play()
    # duration= media.milliseconds()
    # time.sleep(duration)
    time.sleep(10)
    media.stop()
コード例 #24
0
ファイル: music.py プロジェクト: Miriam1996/MyProjects
def play():
    global i
    global clip
    #os.startfile(songs[index])
    data = songs[index]
    clip = mp3play.load(data)
    clip.play()
    currentSong.config(text=songs[index])
コード例 #25
0
ファイル: music play.py プロジェクト: mark199655/music-play
def paly():
    index=listbox.curselection()
    filename=r'%s.mp3'%random.randint(1000,9999)
    urllib.urlretrieve(url_list[index],filename)
    mp3=mp3play.load(filename=filename)
    mp3.play()
    mp3.sleep(time.sleep(mp3.seconds()))
    mp3.stop()
コード例 #26
0
ファイル: server.py プロジェクト: EPAlan/entry-music-facts
def playSongForName(name):
    songsByName = {
        'alex':     ['baba-yetu-short.mp3'],
        'ara':      ['rocky-short.mp3'],
        'angela':   ['conga-short.mp3'],
        'arsineh':  ['black-betty-short.mp3'],
        'bobby':    ['black-keyes-short.mp3'],
        'colette':  ['coco-de-rasta-short.mp3'],
        'cole':     ['super-mario-bros-short.mp3', 'super-mario-bros-short.mp3', 'super-mario-bros-short.mp3', 'super-mario-bros-short.mp3', 'raidersmarch-short.mp3'],
        'erik':     ['im-not-that-girl-short.mp3'],
        'joey':     ['talking-head-short.mp3'],
        'justin':   ['austin-powers-short.mp3'],
        'kate':     ['the-man-in-me-short.mp3'],
        'kumar':    ['give-up-the-funk-short.mp3'],
        'loren':    ['circle-of-life-short.mp3', 'good-morning-short.mp3', 'smooth-criminal-short.mp3', 'hard-victory-short.mp3', 'here-comes-the-sun-short.mp3'],
        'moritz':   ['peponi-short.mp3'],
        'mt':       ['boogie-on-reggae-woman-short.mp3'],
        'neil':     ['chariots-of-fire-short.mp3'],
        'rohan':    ['cotton-eye-joe-short.mp3'],
        'ryan':     ['sexy-and-i-know-it-short.mp3'],
        'soonlen':  ['another-world-short.mp3'],
        'stan':     ['baby-short.mp3'],
        'stephanie':['island-in-the-sun-short.mp3'],
        'sydni':    ['danger-zone-short.mp3'],
        'todd':     ['night-moves-short.mp3'],
        'tracy':    ['super-bass-short.mp3', 'gangnam-style-short.mp3'],
        'guest':    ['the-final-countdown-short.mp3']
    }

    goodbye_songs = [
        'so-long-farewell-short.mp3',
        'so-long-short.mp3',
        'heighho-short.mp3',
        'time-to-say-goodbye-short.mp3',
        'see-you-later-alligator-short.mp3',
        'i-hope-tomorrow-is-like-today-short.mp3',
        'home-short.mp3',
        'gone-short.mp3',
        'already-gone-short.mp3',
        'on-my-way-home-short.mp3',
        'na-na-hey-hey-short.mp3',
        'super-mario-bros-stage-clear.mp3'
    ]

    if time.localtime().tm_hour >= 16:
        filename = random.choice(goodbye_songs)
    else:
        if not songsByName.has_key(name):
            name = 'guest'
        songs = songsByName[name]
        filename = songs[time.localtime().tm_wday % len(songs)]

    print 'Playing song %s for %s' % (filename, name)    
    clip = mp3play.load(path.join('songs', filename))
    clip.play()

    time.sleep(clip.seconds())
    clip.stop()
コード例 #27
0
ファイル: Music.py プロジェクト: gsh978079141/Python3
def play(args):
    try:
        global mp3
    sy = listBox.curselection()[0]
    mp3 = mp3play.load(m_List[int(sy)])
    mp3.play()
    # time.sleep(1000)
    except Exception as e:
    pass
コード例 #28
0
def playsong(data2):
    location = "e:"
    mp = ".mp3"
    mfile = data1
    pfile = location + data1 + mp
    clip = mp3play.load(location + pfile)
    clip.play()
    time.sleep(min(10, clip.seconds()))
    clip.stop()
コード例 #29
0
def play():
    global count
    count += 1
    index = listbox.curselection()
    var1.set(u"正在加载" + listbox.get(index, last=None))
    urllib.urlretrieve(x[index[0]], 'tmp%s.mp3' % str(count))
    var1.set(u"正在播放" + listbox.get(index, last=None))
    mp3 = mp3play.load("tmp%s.mp3" % str(count))
    mp3.play()
    time.sleep(mp3.seconds())
コード例 #30
0
    def play_song(self, name, age):
        while 1:
            if self.play_flag:
                song_url = self.play_song_url
                song_name = self.play_song_name
                # 播放当前列表歌曲
                if len(song_url):
                    # 如果当前环境有firfox则使用firfox进行播放,反之则用MP3play
                    if self.firfox_flag:
                        try:
                            self.driver.get(song_url)
                            self.ui.label.setText(
                                "正在播放: 《{}》...".format(song_name))
                        except:
                            print("play erro : ", song_url)
                    else:
                        if 'migu' in song_url or 'dmhmusic' in song_url or 'xiami' in song_url:
                            pass
                        elif 'qqmusic' in song_url:
                            try:
                                self.mp3 = mp3play.load(song_url + '.mp3')
                                self.mp3.play()
                                self.ui.label.setText(
                                    "正在播放: 《{}》...".format(song_name))
                            except:
                                print("play erro : ", song_url)
                        else:
                            try:
                                self.mp3 = mp3play.load(song_url)
                                self.mp3.play()
                                self.ui.label.setText(
                                    "正在播放: 《{}》...".format(song_name))
                            except:
                                print("play erro : ", song_url)
                self.play_flag = 0

            if self.btn_pause_flag == 1:
                if self.firfox_flag:
                    self.driver.get("http://www.baidu.com")
                else:
                    self.mp3.pause()
                self.btn_pause_flag = 0
                self.ui.label.setText("停止播放")
コード例 #31
0
def play_mp3(filename, max_seconds=5):
    '''
    Play one mp3 file
    '''
    clip = mp3play.load(filename)

    clip.play()
    # Let it play for up to 5 seconds, then stop it.
    time.sleep(min(max_seconds, clip.seconds()))
    clip.stop()
コード例 #32
0
ファイル: sound.py プロジェクト: codepongo/zjdict
def play(f):
    try:
        clip = mp3play.load(f)
        clip.play()
        # Let it play for up to 30 seconds, then stop it.
        import time
        time.sleep(clip.seconds())
        clip.stop()
    except:
        pass
コード例 #33
0
ファイル: PlayLrc.py プロジェクト: heramareh/test
def play(mp3_path, lrc_path):
    mixer.init()
    track = mp3play.load(mp3_path)
    track.play(100)
    if os.path.exists(lrc_path):
        lyrics = Lyrics(lrc_path)
        t_lyric = threading.Thread(target=lyrics.show_lyric)
        t_lyric.start()
        t_lyric.join()
    else:
        print u"not exists"
コード例 #34
0
 def play(self):
     """
     播放音频文件
     :return:
     """
     mp3 = mp3play.load(self.file_path)
     mp3.play()
     sleep_time = min(1800, mp3.seconds())
     time.sleep(sleep_time + 3)
     mp3.stop()
     self.close()
コード例 #35
0
ファイル: music.py プロジェクト: duoyichen/devops
def play():
    index = listbox.curselection()[0]
    #print index
    filename = r'%s.mp3' %random.randint(1000,9999)
    #print url_list[index]
    urllib.urlretrieve(url_list[index],filename)
    mp3 = mp3play.load(filename=filename)
    mp3.play()
    #time.sleep(10)
    time.sleep(mp3.seconds())
    mp3.stop()
コード例 #36
0
ファイル: gui_final.py プロジェクト: bhoom10/bci-media-player
def musicnext():
  global idx 
  global music
  global trackLocations
  global name
  idx+=1
#  print "idx",idx
  music.stop()
  pieces=trackLocations[int(idx)].split("/")
  name.set(pieces[-1])
  music = mp3play.load(trackLocations[int(idx)])
  music.play()
コード例 #37
0
ファイル: get_result.py プロジェクト: StormGuoson/GetResult
 def play_wakeup(self):
     if STOP_ALL:
         return
     for dev in ACTIVE_DEVICES:
         os.popen('adb -s %s shell input tap 300 50' % dev)
     p = mp3play.load(self.wakeup_word)
     p.play()
     time.sleep(p.seconds() + .3)
     for no in range(len(ACTIVE_DEVICES)):
         if not DATA['is_wakeup' + str(no)]:
             self.play_wakeup()
             break
コード例 #38
0
ファイル: gui_final.py プロジェクト: bhoom10/bci-media-player
def tune_changed(event):
   global trackLocations
   global music
   global idx
   global name
   idx = event.widget.curselection()[0]
 #  print "idx",idx
   pieces=trackLocations[int(idx)].split("\\")
   name.set(pieces[-1])
   music = mp3play.load(trackLocations[int(idx)])
   music.play()
   print ("Now playing %s" % event.widget.get(idx))
コード例 #39
0
ファイル: threads.py プロジェクト: nlaurens/SpaceAlert
def randomSiren():
    """


    @return:
    """
    from random import randint
    rnd = randint(0,3)
    if rnd == 0:
        siren = mp3play.load(Settings.soundsDir + Settings.sound['siren1'])
    elif rnd == 1:
        siren = mp3play.load(Settings.soundsDir + Settings.sound['siren1'])
    elif rnd == 2:
        siren = mp3play.load(Settings.soundsDir + Settings.sound['siren2'])
    elif rnd == 3:
        siren = mp3play.load(Settings.soundsDir + Settings.sound['siren3'])
    else:
        print "Error in random int, it retrns: " + str(rnd)
        exit()

    return siren
コード例 #40
0
ファイル: music_player.py プロジェクト: nileskh16/pyjarvis
def play_music():
	mp3list = mp3files()
	for i in random.sample(mp3list, len(mp3list)):
		print i
		clip = mp3play.load(i)
		clip.play()
		fileln = mlength(i)
		secs = clip.seconds()
		print '%d:%d' %(secs/60, secs%60)
		#time.sleep(min(fileln, clip.seconds()))
		time.sleep(30)
		clip.stop()
コード例 #41
0
 def play(self, voice, type = 1):
     suffix = '.wav'
     prefix = config.src
     for temp in voice:
         temp = prefix + temp + suffix
         clip = mp3play.load(temp.encode('gbk'))
         if type:
             clip.play()
             while clip.isplaying():
                 time.sleep(0.1)
             clip.stop()
             continue
コード例 #42
0
ファイル: BD.py プロジェクト: kanamu/assistant
def play(self, path):
    if not os.path.exists(path):
        print '%s not exists' % (path)
        exit()
    UserSys = platform.system()
    if UserSys == 'Windows':
        import mp3play
        mp3 = mp3play.load(path)
        mp3.play()
        time.sleep(mp3.seconds() + 0.1)
    elif UserSys == 'Linux':
        os.system("mpg123 -q %s" % (path))
コード例 #43
0
    def playOne(self, voiceFile, addSeconds, clip=None):
        if clip is None:
            clip = mp3play.load(voiceFile)
        clipSeconds = clip.seconds() + 1
        sleepSeconds = addSeconds + clipSeconds

        clip.volume(90)
        clip.play()
        # time.sleep(clip.seconds())
        time.sleep(clipSeconds)
        clip.stop()
        return clip
コード例 #44
0
ファイル: soundplayer.py プロジェクト: f3n9/ldoce5viewer
 def play(self, data):
     if self._mp3:
         self._mp3.stop()
         self._mp3.close()
         self._mp3 = None
     f = self._get_f()
     if f is None:
         return
     f.write(data)
     path = f.name
     f.close()
     self._mp3 = mp3play.load(path)
     self._mp3.play()
コード例 #45
0
ファイル: sound.py プロジェクト: codepongo/utocode
def play(f):
    if os.path.getsize(f) == 0:
        return
    if sys.platform == 'darwin':
        return os.system('afplay %s' % f)
    try:
        clip = mp3play.load(f)
        clip.play()
        # Let it play for up to 30 seconds, then stop it.
        import time
        time.sleep(clip.seconds())
        clip.stop()
    except:
        pass
コード例 #46
0
ファイル: music_player.py プロジェクト: ShivaGuntuku/Jarvis
def playFile():
	"""function role is to play the random music files collected from
	HDD"""

	mp3list = mp3files()  # collected mp3 files list
	count = len(mp3list)
	for i in random.sample(mp3list, count):
		print i  # which file is played
		clip = mp3play.load(i)
		clip.play()
		filelength = length(i)
		# Let it play for up to 30 seconds, then stop it.
		time.sleep(min(filelength, clip.seconds()))
		clip.stop()
コード例 #47
0
ファイル: client.py プロジェクト: edward-leslie/webdj
	def play_song(self):
		#Make sure user is logged in
		print "playing song "+str(self.logged_in())
		if(self.logged_in()==1):
			print "here"
			#While there are more songs to be played
			while(self.more_songs()):
				#Load the next song from local file
				mp3 = mp3play.load(self.get_song())
				#Play the Song
				mp3.play()
				while mp3.isplaying():
					pass
				mp3.stop()
コード例 #48
0
ファイル: player.py プロジェクト: norandiaconu/Music-Info
def open_file():                                #Opens a dialog box to open .mp3 file
    global music                                #then sends filename to file_name_label.
    global mp3
    global play_list
    filename.set (tkFileDialog.askopenfilename(defaultextension = ".mp3", filetypes=[("All Types", ".*"), ("MP3", ".mp3")]))
    playlist = filename.get()
    playlist_pieces = playlist.split("/")
    play_list.set (playlist_pieces[-1])
    playl = play_list.get()
    play_list_display.insert(END, playl)
    mp3 = filename.get()
    print mp3
    music = mp3play.load(mp3)
    pieces = mp3.split("/")
    name.set (pieces[-1])
コード例 #49
0
ファイル: gui_final.py プロジェクト: bhoom10/bci-media-player
def open_file():
   global play_List
   global trackLocations
   global music
   global name
   filename.set(tkFileDialog.askopenfilename(defaultextension = ".mp3",filetypes=[("All Types", ".*"), ("MP3", ".mp3")]))
   playlist =filename.get()
   playlist_pieces = playlist.split("/")
   play_list.set (playlist_pieces[-1])
   playl = play_list.get()
   play_list_display.insert(END, playl)
#   print filename.get()
   music = mp3play.load(filename.get())
   pieces = filename.get().split("/")
   trackLocations += [filename.get()]
   name.set(pieces[-1])
コード例 #50
0
ファイル: words2voice.py プロジェクト: zhangzhenfeng/marginer
 def playMp3(self,fullpath):
     sysstr = platform.system()
     if(sysstr =="Windows"):
         import mp3play
         mp3 = mp3play.load(fullpath)
         mp3.play()
         time.sleep(min(300, mp3.seconds()))    
         mp3.stop()
     else:
         import pygame
         pygame.mixer.init()
         track1=pygame.mixer.music.load(fullpath)
         pygame.mixer.music.play()
     # 删除文件
     os.remove(fullpath)
     
コード例 #51
0
    def play(self):
        if self.filename is None:
            for hcmd in self.state_list:
                hcmd.execute()
        else:
            mp3 = mp3play.load(self.filename)
            mp3.play()

            # Let it play till the show ends or song does, then stop it.
            for hcmd in self.state_list:
                if GLOBAL_STOP:
                    break
                hcmd.execute()
                if not mp3.isplaying():
                    return
            mp3.stop()
コード例 #52
0
 def fn(self):
     self.txtGotten = self.txt.get(0.0, "end")
     self.txtStripped = self.txtGotten.strip()
     self.txtLowered = self.txtStripped.lower()
     self.txtRegexed = re.sub('[^a-z ]+', '', self.txtLowered)
     self.wordList = self.txtRegexed.split()
     
     for i in self.wordList:
         self.filename = "phrases/" + i + ".mp3"
         try:
             print("Now playing: " + i + ".mp3")
             self.track = mp3play.load(self.filename)
             self.track.play()
             sleep(self.track.seconds() + 0.4)
         except:
             print("NO SUCH FILE FOUND.")
コード例 #53
0
def alarm(sound):
    SOUNDS_NAMES = [
        '24483^pchick-alarm.mp3',
        '35752^CarAlarmSet.mp3',
        '44216^alarm.mp3',
        '71766^alarm.mp3',
        '86502^alarm.mp3',
        '91540^caralarm.mp3',
        '97744^ALARM.mp3',
    ]

    filename = SOUNDS_NAMES[int(sound)]
    clip = mp3play.load(filename)
    clip.play()
    time.sleep(min(30, clip.seconds()))
    clip.stop()
    print "EXIT"
コード例 #54
0
ファイル: woopa.py プロジェクト: rodrwan/woopa_node
  def run(self):
    global status_queue
    global c
    global reset 
    global q
    while True:
      song = q.pop(0)
      data = { 
        "id" : song["id"],
        "file_name" : song["file_name"],
        "like" : song["like"],
        "priority" : song["priority"]
      }
      c.Push(data)
      print "reproduciendo: " + str(song["file_name"])

      if sys.platform == 'win32':
        audio = MP3(song["file_name"])
        mp3 = mp3play.load(song["file_name"])
        mp3.play()
        import time
        try:
          time.sleep(min(audio.info.length, mp3.seconds())) #
        except:
          time.sleep(min((audio.info.length*1000), mp3.milliseconds())) #
        mp3.stop()
      else:
        pygame.mixer.music.load(song["file_name"])
        pygame.mixer.music.play()
        while pygame.mixer.music.get_busy(): 
          pygame.time.Clock().tick(10)
        pygame.mixer.music.stop()     
      c.Pop()
      print "Reseteo en -> " + str(reset)      
      reset -= 1
      if reset <= 0:
        import urllib2
        url = 'woopa.sytes.net'
        response = urllib2.urlopen('http://'+url+'/reset')
        html = response.read()
        reset = 3
        print html
      if len(q) == 0:
        print "Empty queue."
        status_queue = 1
        break
コード例 #55
0
	def playMp3File(self, file="../ressources/tts.mp3"):
		"""
		Play an mp3 file

		Paramters :
			file - File where the mp3 data is storred,
				   ../ressources/tts.mp3 is the default value.
		"""

		try:
			clip = mp3play.load(file)
			clip.play()
			time.sleep(clip.seconds())
			clip.stop()

		except Exception:
			print "Could not play the mp3 file"
コード例 #56
0
    def open_file(self):
        """
Opens a dialog box to open .mp3 filemusic,
then sends filename to file_name_label.
"""
        self.filename.set(tkFileDialog.askopenfilename(
            defaultextension = ".mp3",
            filetypes=[("All Types", ".*"), ("MP3", ".mp3")]))
        self.playlist = self.filename.get()
        playlist_pieces = self.playlist.split("/")
        self.play_list.set (playlist_pieces[-1])
        playl = self.play_list.get()
        self.play_list_display.insert(END, playl)
        print self.filename.get()
        self.music = mp3play.load(self.filename.get())
        pieces = self.filename.get().split("/")
        self.trackLocations += [self.filename.get()]
        self.name.set(pieces[-1])
コード例 #57
0
ファイル: music.py プロジェクト: GapMAX/My-repository
 def run(self):
     self.cond.acquire()
     global sname,i,artist
     time.sleep(1)
     line=l.curselection()[0]
     sname=mlist[line][0]
     artist=mlist[line][1]
     artist=artist.encode('gbk')
     sname=sname.encode('gbk')
     sname=sname+'-'+artist
     urllib.urlretrieve(mlist[line][2],songs_dir+"\%s.mp3"%sname)
     #time.sleep(1)
     mp3=mp3play.load(songs_dir+"\%s.mp3"%sname)
     i=1
     mp3.play()
     rname=sname.decode('gbk')
     state.set(u"playing %s .."%rname)
     self.cond.wait()
     self.cond.release()