def App(self): # 设置start按钮 self.start_button = QPushButton('Start', self) self.start_button.setFont(self.font) self.start_button.resize(200, 100) self.start_button.move(650, 100) #设置stop按钮 self.stop_button = QPushButton('Stop', self) self.stop_button.resize(200, 100) self.stop_button.move(650, 450) self.stop_button.setFont(self.font) # 设置名字显示 self.name_lable = QLineEdit(self) self.name_lable.move(100, 450) self.name_lable.resize(350, 100) self.name_lable.setText('这个人是谁呢?') self.name_lable.setAlignment(Qt.AlignCenter) self.name_lable.setFont(self.font) self.timer = QTimer(self) # 设置图片显示 self.image_lable = QLabel(self) #为图片显示设置一个画布 位置大小 self.image_lable.setGeometry(50, 50, 470, 300) #为图片设置属性 self.image_lable.setStyleSheet("border: 2px solid blue") defaultimage = 'images/开始点名.jpg' self.pnx = QPixmap(defaultimage) # 加载图片路径 self.image_lable.setPixmap(self.pnx) # 将图片显示画布上 self.image_lable.setScaledContents(True) # 图片自适应窗 # 设置开始和结束 # print(self.start_button.isEnabled()) True 可以点击为True 不可以点击为False self.start_button.clicked.connect(lambda: self.start_name()) self.stop_button.clicked.connect(lambda: self.stop()) self.stop_button.clicked.connect( lambda: self.btnsetenabled(self.start_button)) # 设置图片显示 self.start_music = Phonon.createPlayer( Phonon.MusicCategory, Phonon.MediaSource("music/start.mp3")) self.end_music = Phonon.createPlayer( Phonon.MusicCategory, Phonon.MediaSource("music/end.mp3"))
def __init__(self, url, parent = None): #url参数就是你的MP3地址 self.url = url QtGui.QWidget.__init__(self, parent) #设置一些窗口尺寸的策略,不用设置也会有默认策略,干脆注释了,无影响 # self.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Preferred) #创建一个音乐播放器 这是一种简单的方法,功能自然也是很单一,貌似只能实现简单的单首歌曲播放(希望我没有猜错,),更灵活的是使用AudioOutput,MediaObject等方法实现 self.player = Phonon.createPlayer(Phonon.MusicCategory,Phonon.MediaSource(url)) #下面这句话真没搞懂,谷歌了一下 多次尝试没反应 干脆把他注释了。。不影响程序 # self.player.setTickInterval(100) self.player.tick.connect(self.tock) #播放进度改变触发事件 self.play_pause = QtGui.QPushButton(self) #播放按钮 self.play_pause.setIcon(QtGui.QIcon('icons/49heart.svg')) #设置播放按钮图标,jpg,png都可以 self.play_pause.clicked.connect(self.playClicked) #播放按钮单击事件 self.player.stateChanged.connect(self.stateChanged) #播放状态改变触发事件 self.slider = Phonon.SeekSlider(self.player , self) #进度条 self.status = QtGui.QLabel(self) #Label组件用来显示播放的当前时间 self.status.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) #设置Label的对齐方式 左对齐或居中 layout = QtGui.QHBoxLayout(self) #水平布局 layout.addWidget(self.play_pause) #添加播放按钮 layout.addWidget(self.slider) #添加滑动条 layout.addWidget(self.status) #添加播放状态
def __init__(self, parent = None): self.url = "http://listen.radionomy.com/dubsideradio" QtGui.QWidget.__init__(self, parent) self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) self.player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(self.url)) self.player.setTickInterval(100) self.player.tick.connect(self.tock) self.play_pause = QtGui.QPushButton(self) self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(("image/play.jpg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.play_pause.setIcon(self.icon) self.play_pause.setIconSize(QtCore.QSize(23, 24)) self.icon2 = QtGui.QIcon() self.icon2.addPixmap(QtGui.QPixmap(("image/pause.jpg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.play_pause.setFlat(True) self.play_pause.clicked.connect(self.playClicked) self.player.stateChanged.connect(self.stateChanged) self.slider = Phonon.SeekSlider(self.player , self) self.setWindowIcon(self.icon) self.status = QtGui.QLabel(self) self.status.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) layout = QtGui.QHBoxLayout(self) layout.addWidget(self.play_pause) layout.addWidget(self.slider) layout.addWidget(self.status)
def __init__(self, url, parent=None): #url参数就是你的MP3地址 self.url = url QtGui.QWidget.__init__(self, parent) #设置一些窗口尺寸的策略,不用设置也会有默认策略,干脆注释了,无影响 # self.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Preferred) #创建一个音乐播放器 这是一种简单的方法,功能自然也是很单一,貌似只能实现简单的单首歌曲播放(希望我没有猜错,),更灵活的是使用AudioOutput,MediaObject等方法实现 self.player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(url)) #下面这句话真没搞懂,谷歌了一下 多次尝试没反应 干脆把他注释了。。不影响程序 # self.player.setTickInterval(100) self.player.tick.connect(self.tock) #播放进度改变触发事件 self.play_pause = QtGui.QPushButton(self) #播放按钮 self.play_pause.setIcon( QtGui.QIcon('icons/49heart.svg')) #设置播放按钮图标,jpg,png都可以 self.play_pause.clicked.connect(self.playClicked) #播放按钮单击事件 self.player.stateChanged.connect(self.stateChanged) #播放状态改变触发事件 self.slider = Phonon.SeekSlider(self.player, self) #进度条 self.status = QtGui.QLabel(self) #Label组件用来显示播放的当前时间 self.status.setAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) #设置Label的对齐方式 左对齐或居中 layout = QtGui.QHBoxLayout(self) #水平布局 layout.addWidget(self.play_pause) #添加播放按钮 layout.addWidget(self.slider) #添加滑动条 layout.addWidget(self.status) #添加播放状态
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) # Create Phonon Music Player self.phonon = Phonon.createPlayer(Phonon.MusicCategory) self.phonon.stateChanged.connect(self.slotPhononStateChanged) self.phonon.finished.connect(self.slotPhononPlaybackFinished) # Connect signals for buttons self.comboBoxUsers.currentIndexChanged.connect(self.reflectUserProperties) self.pushButtonRecordSample.clicked.connect(self.slotShowRecordWindow) # Enable button when item clicked self.listWidgetEnrollments.itemClicked.connect(lambda: self.pushButtonPlay.setEnabled(True)) # Play sample if double-clicked self.listWidgetEnrollments.itemDoubleClicked.connect(self.slotStartPlayback) # Start/Stop Playback self.pushButtonPlay.clicked.connect(self.slotStartPlayback) self.pushButtonStop.clicked.connect(self.slotStopPlayback) self.pushButtonTrain.clicked.connect(self.slotShowTrainingDialog) self.pushButtonIdentify.clicked.connect(self.slotShowIdentifyDialog) self.pushButtonAddSpeaker.clicked.connect(self.slotAddSpeaker) self.pushButtonPlayTestingSample.clicked.connect(self.slotPlayTestingSample) self.lineEditNewSpeaker.textEdited.connect(self.slotCheckNewSpeaker) # Create Marf instance self.marf = Marf() # Fill speaker list self.fill_speaker_list()
def __init__(self, url, parent=None): self.url = url QtGui.QWidget.__init__(self, parent) self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) self.player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(url)) self.player.setTickInterval(100) self.player.tick.connect(self.tock) self.play_pause = QtGui.QPushButton(self) self.play_pause.setIcon(QtGui.QIcon(":/icons/player_play.svg")) self.play_pause.clicked.connect(self.playClicked) self.player.stateChanged.connect(self.stateChanged) self.slider = Phonon.SeekSlider(self.player, self) self.status = QtGui.QLabel(self) self.status.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.download = QtGui.QPushButton("Download", self) self.download.clicked.connect(self.fetch) layout = QtGui.QHBoxLayout(self) layout.addWidget(self.play_pause) layout.addWidget(self.slider) layout.addWidget(self.status) layout.addWidget(self.download)
def __init__(self, url, parent=None): self.url = url QtGui.QWidget.__init__(self, parent) self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) self.player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(url)) self.player.setTickInterval(100) self.player.tick.connect(self.tock) self.play_pause = QtGui.QPushButton(self) self.play_pause.setIcon(QtGui.QIcon(':/icons/player_play.svg')) self.play_pause.clicked.connect(self.playClicked) self.player.stateChanged.connect(self.stateChanged) self.slider = Phonon.SeekSlider(self.player, self) self.status = QtGui.QLabel(self) self.status.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.download = QtGui.QPushButton("Download", self) self.download.clicked.connect(self.fetch) layout = QtGui.QHBoxLayout(self) layout.addWidget(self.play_pause) layout.addWidget(self.slider) layout.addWidget(self.status) layout.addWidget(self.download)
def __init__(self, listaRep): self.listaRep = listaRep self.cancion_actual = listaRep._head self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory) self.phonon = Phonon.MediaObject() self.phonon = Phonon.createPlayer(Phonon.MusicCategory) Phonon.createPath(self.phonon, self.audioOutput) self.phonon.setCurrentSource(Phonon.MediaSource(self.cancion_actual.song.archivo))
def play(self, filename): if not self.music: self.music = Phonon.createPlayer(Phonon.MusicCategory) if self.music.state == Phonon.PlayingState: self.music.enqueue(filename) else: self.music.enqueue(Phonon.MediaSource(filename)); self.music.play()
def __init__(self, listaRep): self.listaRep = listaRep self.cancion_actual = listaRep._head self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory) self.phonon = Phonon.MediaObject() self.phonon = Phonon.createPlayer(Phonon.MusicCategory) Phonon.createPath(self.phonon, self.audioOutput) self.phonon.setCurrentSource( Phonon.MediaSource(self.cancion_actual.song.archivo))
def __init__ (self): self.audio = Phonon.createPlayer(Phonon.MusicCategory) self.totalTime = 0 self.audioSource = None self.audio.totalTimeChanged.connect(self.onTotalTimeChanged) self.nowPlaying = None self.library = MediaLibrary() self.library.loadFromDirectory(r'C:\files\dropbox\music') self.queue = MediaQueue(self.library)
def __init__(self, soundFile, POOL_COUNT=3): self.state = True self.soundFile = soundFile self.resourcePool = deque() self.current = None self.POOL_COUNT = POOL_COUNT for i in xrange(self.POOL_COUNT): #self.resourcePool.append( QSound(soundFile) ) player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(soundFile)); self.resourcePool.append(player)
def __init__(self, playList = [], ddir = "data"): self._currentIndex = 0 try: self._playList = playList # 播放列表 self.playList = [Phonon.MediaSource(QUrl(item[1].format(DATA_DIR = ddir))) for item in self._playList] # 播放器 self.player = Phonon.createPlayer(Phonon.MusicCategory) self.player.setTickInterval(1000) except Exception as e: traceback.print_exc(e)
def init_phonon(self): if not self.player: self.player = Phonon.createPlayer(Phonon.MusicCategory) self.m_audio = Phonon.AudioOutput(Phonon.MusicCategory, self) Phonon.createPath(self.player, self.m_audio) self.player.setTickInterval(100) # actions self.player.tick.connect(self.player_tick) self.player.finished.connect(self.player_finished) # QSlider -> SeekSlider self.slider_time = Phonon.SeekSlider(self.player, self)
def __init__(self, playList=[], ddir="data"): self._currentIndex = 0 try: self._playList = playList # 播放列表 self.playList = [ Phonon.MediaSource(QUrl(item[1].format(DATA_DIR=ddir))) for item in self._playList ] # 播放器 self.player = Phonon.createPlayer(Phonon.MusicCategory) self.player.setTickInterval(1000) except Exception as e: traceback.print_exc(e)
def playURL(self, url): """Toma la URL de un playlist, y empieza a hacer ruido""" data = parse_pls(url) if data: # Tengo una URL # Sí, tomamos el primer stream y listo. url = data[0][1] self.player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(url)) self.player.play() else: # Pasó algo malo QtGui.QMessageBox.information(None, "Radio - Error reading playlist", "Sorry, error starting this radio.")
def playURL(self, url): """Toma la URL de un playlist, y empieza a hacer ruido""" data = parse_pls(url) if data: # Tengo una URL # la anoto self.playingURL = url # Sí, tomamos el primer stream y listo. url = data[0][1] self.player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(url)) self.player.play() # Notificar cada cambio en metaData (qué se esta escuchando) self.player.metaDataChanged.connect(self.notify) else: # Pasó algo malo QtGui.QMessageBox.information(None, self.tr("Radio - Error reading playlist"), self.tr("Sorry, error starting this radio."))
def __init__(self, parent=None): super(MainWidget, self).__init__(parent) # set app name before mediaObject was created to avoid phonon problem QCoreApplication.setApplicationName("NetEaseMusic-ThirdParty") self.ui = UiMainWidget() self.ui.setup_ui(self) self.signal_mapper = QSignalMapper(self) self.player = Phonon.createPlayer(Phonon.MusicCategory) self.net_manager = QNetworkAccessManager() self.searchShortcut = QShortcut(QKeySequence("Ctrl+F"), self) self.sources = [] self.net_ease = NetEase() self.model = DataModel() self.set_self_prop() self.set_signal_binding() self.init_table_widget()
def playURL(self, url): """Toma la URL de un playlist, y empieza a hacer ruido""" data = parse_pls(url) if data: # Tengo una URL # la anoto self.playingURL = url # Sí, tomamos el primer stream y listo. url = data[0][1] self.player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(url)) self.player.play() # Notificar cada cambio en metaData (qué se esta escuchando) self.player.metaDataChanged.connect(self.notify) else: # Pasó algo malo QtGui.QMessageBox.information( None, self.tr("Radio - Error reading playlist"), self.tr("Sorry, error starting this radio."))
def __init__ (self, parent, playlist, busName, busPath): SatyrObject.__init__ (self, parent, busName, busPath) self.configValues= ( # actually it doesn't make much sense to save this one ('state', int, Player.STOPPED), ('stopAfter', configEntryToBool, False), # or this one... ('quitAfter', configEntryToBool, False), ) self.loadConfig () self.playlist= playlist self.media= Phonon.createPlayer (Phonon.MusicCategory) # self.media.finished.connect (self.next) # self.media.finished.connect () self.media.aboutToFinish.connect (self.queueNext) self.media.currentSourceChanged.connect (self.sourceChanged) self.media.stateChanged.connect (self.stateChanged)
def play(url): if PLAYER == "phonon": app = QApplication(sys.argv, applicationName="Google Music playing test") media = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(url)) media.play() # Trick to allow Ctrl+C to exit. signal.signal(signal.SIGINT, signal.SIG_DFL) sys.exit(app.exec_()) elif PLAYER == "gst": player = gst.element_factory_make("playbin2", "player") player.set_property("uri", url) player.set_state(gst.STATE_PLAYING) glib.MainLoop().run() else: import subprocess subprocess.call(["ffplay", "-vn", "-nodisp", "%s" % url]) return
def __init__(self, autoProxy=False, parent=None) : super(VocDialog, self).__init__(parent) self.logger = getLogger('VocVoc.VocDialog') self.info = self.logger.info self.warn = self.logger.warn self.debug = self.logger.debug if autoProxy : self.info('Starting VocDialog with autoProxy.') else : self.info('Starting VocDialog without autoProxy.') self.mediaObeject = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource('')) self.setupUi() self.connect() self.initCountWord() self.candidates = None self.autoProxy = autoProxy self.spellChecker = SpellChecker() self.correct = self.spellChecker.correct self.corpusDir = self.spellChecker.corpusDir self.info('VocDialog started.')
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) # Create Phonon Music Player self.phonon = Phonon.createPlayer(Phonon.MusicCategory) self.phonon.stateChanged.connect(self.slotPhononStateChanged) self.phonon.finished.connect(self.slotPhononPlaybackFinished) # Connect signals for buttons self.comboBoxUsers.currentIndexChanged.connect( self.reflectUserProperties) self.pushButtonRecordSample.clicked.connect(self.slotShowRecordWindow) # Enable button when item clicked self.listWidgetEnrollments.itemClicked.connect( lambda: self.pushButtonPlay.setEnabled(True)) # Play sample if double-clicked self.listWidgetEnrollments.itemDoubleClicked.connect( self.slotStartPlayback) # Start/Stop Playback self.pushButtonPlay.clicked.connect(self.slotStartPlayback) self.pushButtonStop.clicked.connect(self.slotStopPlayback) self.pushButtonTrain.clicked.connect(self.slotShowTrainingDialog) self.pushButtonIdentify.clicked.connect(self.slotShowIdentifyDialog) self.pushButtonAddSpeaker.clicked.connect(self.slotAddSpeaker) self.pushButtonPlayTestingSample.clicked.connect( self.slotPlayTestingSample) self.lineEditNewSpeaker.textEdited.connect(self.slotCheckNewSpeaker) # Create Marf instance self.marf = Marf() # Fill speaker list self.fill_speaker_list()
def __init__(self, file_path): self.sound = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(file_path))
def __init__(self, model): self._model = model # Media playing interface provided by Phonon stack. self._media = Phonon.createPlayer(Phonon.MusicCategory) # Connect signal to progress song playback. self._media.aboutToFinish.connect(self.play_next)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.lcdcurrent.display("00:00") self.ui.lcdtotal.display("00:00") self.PORT = False self.SHOW = False self.songs = [] self.chosen = 0 ###### WINDOW SETTINGS ###### try: self.setAttribute(QtCore.Qt.WA_Maemo5StackedWindow, True) self.setAttribute(QtCore.Qt.WA_Maemo5AutoOrientation, True); except: pass self.setWindowTitle("MaAmp - Offline") # Should show artist name here self.connect(QtGui.QApplication.desktop(), QtCore.SIGNAL("resized(int)"), self.orientationChanged ); ### SETUP CUSTOM LABEL, PUSHLABEL ### self.ui.cover_art = pushLabel(self) self.ui.cover_art.setGeometry(QtCore.QRect(20, 35, 280, 280)) self.ui.cover_art.setScaledContents(True) #self.ui.cover_art.setPixmap(QtGui.QPixmap(current[3])) self.ui.cover_art.setPixmap(QtGui.QPixmap(os.path.dirname(os.path.realpath( __file__ ) )+"/empty.png")) self.connect(self.ui.cover_art, QtCore.SIGNAL("clicked()"),self.animate) ### INIT THINGS ### self.getconnected() self.disablebuttons() ### ACTIONBUTTONS (MENU) ### self.connect(self.ui.actionConfigure, QtCore.SIGNAL("triggered()"),self.configure) self.connect(self.ui.actionAbout, QtCore.SIGNAL("triggered()"),self.about) self.connect(self.ui.actionFM_Radio, QtCore.SIGNAL('triggered()'), self.fmradio) self.connect(self.ui.actionClearRefresh, QtCore.SIGNAL('triggered()'), self.clearrefresh) ### BUTTONS ### self.connect(self.ui.artistsButton, QtCore.SIGNAL("clicked()"),self.listartists) #self.connect(self.ui.albumsButton, QtCore.SIGNAL("clicked()"),self.listalbums) ### PLAYER BUTTONS ### self.connect(self.ui.playButton, QtCore.SIGNAL("clicked()"),self.play) self.connect(self.ui.stopButton, QtCore.SIGNAL("clicked()"),self.stop) self.connect(self.ui.nextButton, QtCore.SIGNAL("clicked()"),self.next) self.connect(self.ui.previousButton, QtCore.SIGNAL("clicked()"),self.prev) self.connect(self.ui.listWidget, QtCore.SIGNAL("itemClicked(QListWidgetItem*)"), self.itemClicked) ### INIT ALL ANIMATIONS ### self.f_animate = QtCore.QPropertyAnimation(self.ui.frame, "geometry") self.f_animate.setDuration(ANIMSPEED) self.f2_animate = QtCore.QPropertyAnimation(self.ui.frame_2, "geometry") self.f2_animate.setDuration(ANIMSPEED) self.l_animate = QtCore.QPropertyAnimation(self.ui.listWidget, "geometry") self.l_animate.setDuration(ANIMSPEED) ### ANIMATION GEOMETRY ### ### PORTRAIT ### self.fp_visible = QtCore.QRect(35, 655, 411, 91) self.fp_invisible = QtCore.QRect (35, 810, 411, 91) self.f2p_visible = QtCore.QRect (0, 330, 480, 311) self.f2p_invisible = QtCore.QRect (490, 330, 480, 311) self.lp_visible = QtCore.QRect (0, 330, 480, 430) self.lp_invisible = QtCore.QRect (490, 330, 480, 430) ### LANDSCAPE ### self.fl_visible = QtCore.QRect (360, 330, 411, 91) self.fl_invisible = QtCore.QRect (360, 490, 411, 91) self.f2l_visible = QtCore.QRect (320, 5, 480, 311) self.f2l_invisible = QtCore.QRect (810, 5, 480, 311) self.ll_visible = QtCore.QRect (320, 0, 480, 430) self.ll_invisible = QtCore.QRect (810, 0, 480, 430) ### SETUP & INIT PHONON SOUND ### self.mediaObject = Phonon.createPlayer(Phonon.MusicCategory) self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory) #print self.audioOutput.outputDevice().name() self.mediaObject.setTickInterval(1000) self.mediaObject.tick.connect(self.tick) self.mediaObject.stateChanged.connect(self.stateChanged) self.mediaObject.currentSourceChanged.connect(self.sourceChanged) self.mediaObject.aboutToFinish.connect(self.aboutToFinish) self.mediaObject.finished.connect(self.finished) ### CREATE AND CONNCT SEEKSLIDER TO PHONON ### self.ui.seekSlider = Phonon.SeekSlider(self.mediaObject,self.ui.frame_2) self.ui.seekSlider.setGeometry(QtCore.QRect(10, 245, 268, 61)) self.ui.seekSlider.setOrientation(QtCore.Qt.Horizontal) self.ui.seekSlider.setObjectName("seekSlider") ### JUST TO UPDATE SCREEN... HMMM.... ### self.animate()
def initgl(self): # open activations file and store it in an organized manner in a list. with open("activations") as f: data = [] i = 0 for line in f: temp = line.strip().split() if temp[-1] == "[": data.append([]) elif temp[-1] != "]": ins = [float(j) for j in temp] data[i].append(ins) else: ins = [float(j) for j in temp[:-1]] data[i].append(ins) i += 1 # number - number of layers in the DNN model. # global number # number = i self.progress.setValue(60) # alpha is the smoothing constraint. vcol holds the activations after smoothing. global alpha alpha = 0.5 global vcol vcol = [[] for i in range(number)] # use threading with threads for each layer to make computation faster t = [] for l in range(number): t.append( threading.Thread(target=self.smoothing, args=( data[l], l, ))) t[l].start() for l in range(number): t[l].join() self.progress.setValue(70) #jet = cm = plt.get_cmap('jet') #cNorm = colors.Normalize() #scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet) # give color to each vertex of the triangle according to the activation of that neuron (used jet color map) col = [[] for i in range(number)] for l in range(number): for fr in range(len(data[l])): col[l].append([]) #col[l][fr] = scalarMap.to_rgba(vcol[l][fr]) col[l][fr] = plt.cm.jet( plt.Normalize(min(vcol[l][fr]), max(vcol[l][fr]))(vcol[l][fr])).tolist() self.progress.setValue(80) self.frames = len(col[0]) # total no of frames in the wav file. print "No. of frames ", self.frames # make triplets of the rgba values got after colormap in order to pass them to their respective vertices global real_col real_col = [[] for i in range(number)] for i in range(number): k = 0 indices = self.foldername + "/lda/" + str( i + 1 ) + "/indices" # file containing the set of vertices after Delaunay Triangulation. with open(indices) as f: for line in f: p = map(int, line.split()) for fr in range(self.frames): if k == 0: real_col[i].append([]) real_col[i][fr].append(col[i][fr][p[0] - 1]) real_col[i][fr].append(col[i][fr][p[1] - 1]) real_col[i][fr].append(col[i][fr][p[2] - 1]) k = 1 self.progress.setValue(90) self.resize(1200, 600) self.move(100, 50) totaldata = [] for i in range(number): data = np.zeros(len(real_ver[i]), [ ("position", np.float32, 2), ("color", np.float32, 4) ]) # data structure to store position and color for each vertex. data['color'] = real_col[i][0] data['position'] = real_ver[i] totaldata.append( data) # list of all vertices with their position and color. # add UI stuff self.player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource("output.wav")) self.playsongButton = QtGui.QPushButton("Play/Pause Audio") self.playsongButton.clicked.connect(self.playsong) self.midLayout.addWidget(self.playsongButton) self.frSlider = self.createSlider() self.frSlider.setValue(0) self.frSlider.valueChanged.connect(self.setline) self.frameno = QtGui.QLabel("Enter Frame No.[1-" + str(self.frames) + "]:") self.frameno.setFixedWidth(160) self.lineedit = QtGui.QLineEdit("1") self.lineedit.setFixedWidth(75) self.lineedit.returnPressed.connect(self.setslider) self.gobutton = QtGui.QPushButton("Go!") self.gobutton.setFixedWidth(75) self.gobutton.clicked.connect(self.setslider) self.playButton = QtGui.QPushButton("Play") self.pauseButton = QtGui.QPushButton("Pause") self.stopButton = QtGui.QPushButton("Stop") self.playButton.clicked.connect(self.playvalue) self.pauseButton.clicked.connect(self.pausevalue) self.stopButton.clicked.connect(self.stopvalue) self.glWidget = [] self.label = [] # create OpenGL windows for each layer by creating object of the FrWidget class. for i in range(number): awindow = FrWidget(i, totaldata[i]) self.glWidget.append(awindow) self.frSlider.valueChanged.connect(self.glWidget[i].setFrame) lname = "Layer" + str(i + 1) alabel = QtGui.QLabel(lname) self.label.append(alabel) self.mainLayout.addWidget(self.label[i], 2 + (i // 3) * 2, i % 3) self.mainLayout.addWidget(self.glWidget[i], 3 + (i // 3) * 2, i % 3) # add all things to mainlayout self.mainLayout.addWidget(self.frSlider, 4 + (number // 3) * 2, 0, 1, min(number, 3)) self.partLayout = QtGui.QHBoxLayout() self.partLayout.addWidget(self.frameno) self.partLayout.addWidget(self.lineedit) self.partLayout.addWidget(self.gobutton) self.partLayout.addWidget(self.playButton) self.partLayout.addWidget(self.pauseButton) self.partLayout.addWidget(self.stopButton) self.mainLayout.addLayout(self.partLayout, 5 + (number // 3) * 2, 0, 1, min(number, 3)) self.progress.setValue(100)
try: if thread.wantsToQuit(): return [] except AttributeError: pass (is_ad, correlation) = db.check_signature(segment.signature) segments.append((segment, is_ad, correlation)) db.file_checked() db.save() return segments def close(self): # Remove temporary files for (segment, _, _) in self.segmentData: segment.remove_soundfile() return QMainWindow.close(self) app = QApplication(sys.argv) app.setApplicationName("guidetect") app.setOrganizationName("pafcu") player = Phonon.createPlayer(Phonon.NoCategory) try: initial_path = sys.argv[1] except IndexError: initial_path = None wnd = MainWindow(initial_path) wnd.show() app.exec_()
def __init__(self): QtGui.QWidget.__init__(self) vbox = QtGui.QVBoxLayout(self) self.setWindowTitle("Frederic Music Player") self.move(400, 200) self.label = QtGui.QLabel(self) self.status = QtGui.QLabel(self) self.play = QtGui.QPushButton("Play") self.pause = QtGui.QPushButton("Pause") self.stop = QtGui.QPushButton("Stop") self.siguiente = QtGui.QPushButton("Siguiente") self.anterior = QtGui.QPushButton("Anterior") self.listWidget = QtGui.QListWidget(self) self.agregar = QtGui.QPushButton("Agregar") self.eliminar = QtGui.QPushButton("Eliminar") self.artist = None self.song = None # Phonon settings self.player = Phonon.createPlayer(Phonon.MusicCategory) self.player.setTickInterval(100) self.player.tick.connect(self.ticking) self.spin = Phonon.SeekSlider(self.player, self) # Implementing the layout vbox.addWidget(self.label) vbox.addWidget(self.status) hbox0 = QtGui.QHBoxLayout(self) hbox0.addWidget(self.play) hbox0.addWidget(self.pause) hbox0.addWidget(self.stop) hbox0.addWidget(self.anterior) hbox0.addWidget(self.siguiente) vbox.addLayout(hbox0) vbox.addWidget(self.listWidget) hbox = QtGui.QHBoxLayout(self) hbox.addWidget(self.agregar) hbox.addWidget(self.eliminar) vbox.addLayout(hbox) vbox.addWidget(self.spin) self.setLayout(vbox) self.play.clicked.connect(self.funcPlay) self.agregar.clicked.connect(self.funcAgregar) self.eliminar.clicked.connect(self.funcEliminar) self.pause.clicked.connect(lambda: self.player.pause()) self.stop.clicked.connect(lambda: self.player.stop()) self.player.aboutToFinish.connect(self.nextSongQueued) self.siguiente.clicked.connect(self.nextSong) self.anterior.clicked.connect(self.previousSong) self.file_name = None self.data = None self.songs = {} self.SongPlaying = None self.SongQueued = None
def initgl(self): # open activations file and store it in an organized manner in a list. with open("activations") as f: data = [] i=0 for line in f: temp = line.strip().split() if temp[-1] == "[": data.append([]) elif temp[-1] != "]": ins = [float(j) for j in temp] data[i].append(ins) else: ins = [float(j) for j in temp[:-1]] data[i].append(ins) i+=1 # number - number of layers in the DNN model. # global number # number = i self.progress.setValue(60) # alpha is the smoothing constraint. vcol holds the activations after smoothing. global alpha alpha = 0.5 global vcol vcol=[[] for i in range(number)] # use threading with threads for each layer to make computation faster t=[] for l in range(number): t.append(threading.Thread(target=self.smoothing, args=(data[l],l,))) t[l].start() for l in range(number): t[l].join() self.progress.setValue(70) #jet = cm = plt.get_cmap('jet') #cNorm = colors.Normalize() #scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet) # give color to each vertex of the triangle according to the activation of that neuron (used jet color map) col=[[] for i in range(number)] for l in range(number): for fr in range(len(data[l])): col[l].append([]) #col[l][fr] = scalarMap.to_rgba(vcol[l][fr]) col[l][fr] = plt.cm.jet(plt.Normalize(min(vcol[l][fr]),max(vcol[l][fr]))(vcol[l][fr])).tolist() self.progress.setValue(80) self.frames = len(col[0]) # total no of frames in the wav file. print "No. of frames ",self.frames # make triplets of the rgba values got after colormap in order to pass them to their respective vertices global real_col real_col=[[] for i in range(number)] for i in range(number): k=0 indices = self.foldername + "/lda/" + str(i+1) + "/indices" # file containing the set of vertices after Delaunay Triangulation. with open(indices) as f: for line in f: p = map(int,line.split()) for fr in range(self.frames): if k==0: real_col[i].append([]) real_col[i][fr].append(col[i][fr][p[0]-1]) real_col[i][fr].append(col[i][fr][p[1]-1]) real_col[i][fr].append(col[i][fr][p[2]-1]) k=1 self.progress.setValue(90) self.resize(1200,600) self.move(100,50) totaldata = [] for i in range(number): data = np.zeros(len(real_ver[i]), [("position", np.float32, 2), ("color", np.float32, 4)]) # data structure to store position and color for each vertex. data['color'] = real_col[i][0] data['position'] = real_ver[i] totaldata.append(data) # list of all vertices with their position and color. # add UI stuff self.player = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource("output.wav")) self.playsongButton = QtGui.QPushButton("Play/Pause Audio") self.playsongButton.clicked.connect(self.playsong) self.midLayout.addWidget(self.playsongButton) self.frSlider = self.createSlider() self.frSlider.setValue(0) self.frSlider.valueChanged.connect(self.setline) self.frameno = QtGui.QLabel("Enter Frame No.[1-" + str(self.frames) + "]:") self.frameno.setFixedWidth(160) self.lineedit = QtGui.QLineEdit("1") self.lineedit.setFixedWidth(75) self.lineedit.returnPressed.connect(self.setslider) self.gobutton = QtGui.QPushButton("Go!") self.gobutton.setFixedWidth(75) self.gobutton.clicked.connect(self.setslider) self.playButton = QtGui.QPushButton("Play") self.pauseButton = QtGui.QPushButton("Pause") self.stopButton = QtGui.QPushButton("Stop") self.playButton.clicked.connect(self.playvalue) self.pauseButton.clicked.connect(self.pausevalue) self.stopButton.clicked.connect(self.stopvalue) self.glWidget = [] self.label = [] # create OpenGL windows for each layer by creating object of the FrWidget class. for i in range(number): awindow = FrWidget(i, totaldata[i]) self.glWidget.append(awindow) self.frSlider.valueChanged.connect(self.glWidget[i].setFrame) lname = "Layer" + str(i+1) alabel = QtGui.QLabel(lname) self.label.append(alabel) self.mainLayout.addWidget(self.label[i],2+(i//3)*2,i%3) self.mainLayout.addWidget(self.glWidget[i],3+(i//3)*2,i%3) # add all things to mainlayout self.mainLayout.addWidget(self.frSlider,4+(number//3)*2,0,1,min(number,3)) self.partLayout = QtGui.QHBoxLayout() self.partLayout.addWidget(self.frameno) self.partLayout.addWidget(self.lineedit) self.partLayout.addWidget(self.gobutton) self.partLayout.addWidget(self.playButton) self.partLayout.addWidget(self.pauseButton) self.partLayout.addWidget(self.stopButton) self.mainLayout.addLayout(self.partLayout,5+(number//3)*2,0,1,min(number,3)) self.progress.setValue(100)
def _player(self): return Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(self.path))
def __init__(self, parent, temp_dir): self._player = Phonon.createPlayer(Phonon.NoCategory) self._player.finished.connect(self._onFinished) self._alive = set()
def __init__(self, parent=None, flag=QtCore.Qt.Widget): QtGui.QMainWindow.__init__(self, parent, flag) self.ui = main.Ui_MainWindow() self.ui.setupUi(self) self.score = (0,0) self.started = False # default settings self.digits = 1 self.rows = 5 self.flash = 500 self.timeout = 1500 self.neg = False self.speech = False self.one_digit = False self.fullscreen = False self.hands_free = False self.tmpwav= None self.replay = False self.noscore = False self.history = [] self.font_color = None self.background_color = None self.annoying_sound = False self.no_plus_sign = False self.isLabelClearable = True self.geometryLabel = None self.timerUpdateLabel = QtCore.QTimer() self.timerUpdateLabel.setSingleShot(True) self.connect(self.timerUpdateLabel, QtCore.SIGNAL('timeout()'), self.updateLabel) self.timerShowAnswer = QtCore.QTimer() self.timerShowAnswer.setSingleShot(True) self.connect(self.timerShowAnswer, QtCore.SIGNAL('timeout()'), self.showAnswer) self.timerRestartPlay = QtCore.QTimer() self.timerRestartPlay.setSingleShot(True) self.connect(self.timerRestartPlay, QtCore.SIGNAL('timeout()'), self.restartPlay) if IS_SYSTEMRANDOM_AVAILABLE: self.randint = SystemRandom().randint else: self.randint = randint self.ui.label.clear() # using an inputmask gives a bug when double clicking in any other apps if le_answer has the focus #self.ui.le_answer.setInputMask('000000009') self.ui.l_total.hide() self.shortcut_F11 = QtGui.QShortcut(QtGui.QKeySequence('F11'), self) self.connect(self.shortcut_F11, QtCore.SIGNAL('activated()'), self.updateFullScreen) self.shortcut_Enter = QtGui.QShortcut(QtGui.QKeySequence('Enter'), self) self.connect(self.shortcut_Enter, QtCore.SIGNAL('activated()'), self.ui.pb_start.click) self.connect(self.ui.pb_check, QtCore.SIGNAL('clicked()'), self.updateAnswer) self.connect(self.ui.pb_settings, QtCore.SIGNAL('clicked()'), self.changeSettings) self.connect(self.ui.pb_exit, QtCore.SIGNAL('clicked()'), self.close) self.connect(self.ui.pb_start, QtCore.SIGNAL('clicked()'), self.startPlay) self.connect(self.ui.pb_replay, QtCore.SIGNAL('clicked()'), self.redisplaySequence) self.ui.label.setPixmap(QtGui.QPixmap(WELCOME)) if IS_PHONON_AVAILABLE: self.player = Phonon.createPlayer(Phonon.AccessibilityCategory, Phonon.MediaSource('')) self.connect(self.player, QtCore.SIGNAL('stateChanged(Phonon::State, Phonon::State)'), self.cleanup) self.importSettings() # change background and foreground color if needed stylesheet = [] if self.background_color is not None: stylesheet.append('background-color: %s' % self.background_color) if self.font_color is not None: stylesheet.append('color: %s' % self.font_color) if stylesheet != []: self.ui.label.setStyleSheet(';'.join(stylesheet)) # add url in statusbar self.ui.statusbar.showMessage('sorobanexam.org') if self.fullscreen: self.showFullScreen() else: self.showNormal() # resize font font = self.ui.label.font() # width is the size of of '+9999' in the current font width = QtGui.QFontMetrics(font).width('+'+'9'*(self.digits+2)) # the factor to multiply by to use the max. space factor = float(self.ui.gb_number.width())/width newPointSize = min(int(font.pointSize()*factor), self.ui.gb_number.height()) font.setPointSize(newPointSize) self.ui.label.setFont(font)
import sys from PyQt4 import QtCore from PyQt4.phonon import Phonon app = QtCore.QCoreApplication(sys.argv) app.setApplicationName("my_player") # phonon useage requires an application name m = Phonon.MediaSource("temp.wav") obj = Phonon.createPlayer(Phonon.MusicCategory, m) obj.play() app.exec_()
def __init__(self): QtGui.QMainWindow.__init__(self) self.setWindowFlags( QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint | QtCore.Qt.X11BypassWindowManagerHint ) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setStyleSheet("background-color:transparent;") desktop = QtGui.qApp.desktop() self.setGeometry(desktop.rect()) self.capture_width=640 self.capture_height=480 self.labels = [] self.pix = None self.alarms = [] for (dirpath, dirnames, filenames) in os.walk("assets/alarms"): for filename in filenames: if os.path.splitext(filename)[1] == '.mp3': m = Phonon.MediaSource(os.path.join(dirpath, filename)) self.alarms.append(Phonon.createPlayer(Phonon.MusicCategory, m)) print "loaded %s" % filename self.font = QtGui.QFont('Impact', 50) self.font.setHintingPreference(QtGui.QFont.PreferDefaultHinting) self.font.setStyleStrategy(QtGui.QFont.PreferAntialias) self.font.setStyle(QtGui.QFont.StyleNormal) self.font.setWeight(QtGui.QFont.Normal) self.caught_dir = 'caught' try: os.makedirs(self.caught_dir) except OSError as e: if e.errno not in (errno.EEXIST,): raise print "saving captures to %s" % self.caught_dir # clear the screen after 30 seconds self.clear_timer = QtCore.QTimer() self.clear_timer.setInterval(30 * 1000) self.clear_timer.setSingleShot(True) self.clear_timer.timeout.connect(self.clear) # record video at 10 fps self.capture_fourcc = cv2.cv.CV_FOURCC(*'XVID') self.capture_fps = 10 self.camera = None self.writer = None self.capture_frame_timer = QtCore.QTimer(self) self.capture_frame_timer.setInterval(1000/self.capture_fps) self.capture_frame_timer.timeout.connect(self.capture_frame_timer_handler) # stop recording after 10 seconds self.capture_stop_timer = QtCore.QTimer(self) self.capture_stop_timer.setInterval(10 * 1000) self.capture_stop_timer.setSingleShot(True) self.capture_stop_timer.timeout.connect(self.capture_stop_timer_handler) # load captions self.captions = captions.load_captions() self.caption_top, self.caption_bottom = captions.choose(self.captions)
import sys from PyQt4 import QtGui from PyQt4.phonon import Phonon app = QtGui.QApplication(sys.argv) url="AirbeatProject-AirbeatOne.mp3" w = QtGui.QWidget() audio = Phonon.createPlayer(Phonon.MusicCategory, Phonon.MediaSource(url)) w.setMinimumSize(100,100) w.show() audio.play() sys.exit(app.exec_())