def localFile(): a = tkinter.filedialog.askopenfilename(initialdir="/", title="Select file", filetypes=[("wav files", "*.wav")]) print(a) global theFile if a.endswith(".wav") and len(a) > 4: theFile = a B6 = App.getNewButton("Play", 0, 1) B6['command'] = lambda: play_audio(theFile) B5 = App.getNewButton("Back", 1, 1) B5['command'] = lambda: continueTo(B5, B6, B1, B3, B8, B11) B11 = App.getNewButton("Analyse", 2, 1) B11['command'] = lambda: goToAnalyse2(B1, B3, B8, B5, B6, B11) hideHome(B1, B3, B8)
def getSelection(sb, lb, B9, B10, B1): restore(sb, lb, B9, B10) global theFile value = lb.get(lb.curselection()) print(value) if value.endswith(".wav") and value != ".wav": theFile = value B2 = App.getNewButton("Rename", 1, 1) B5 = App.getNewButton("Back", 3, 0) B6 = App.getNewButton("Play", 0, 1) B7 = App.getNewButton("Delete", 2, 1) B11 = App.getNewButton("Analyse", 3, 1) B2['command'] = lambda: Rename(B2, B5, B6, B7, B11) B5['command'] = lambda: switchButton(B1, B2, B5, B6, B7, B3, B8, B11) B7['command'] = lambda: [ switchButton(B1, B2, B5, B6, B7, B3, B8, B11), delete(theFile) ] B6['command'] = lambda: play_audio(theFile) B11['command'] = lambda: goToAnalyse(B1, B3, B8, B2, B5, B6, B7, B11)
def recordMusic(): rec = Recording() global theFile localtime = time.asctime(time.localtime(time.time())) rec.start() hideHome(B1, B3, B8) b = tkinter.messagebox.askokcancel('tips', 'Recording...\nPress OK to stop.') if b: print("Stop recording") rec.stop() theFile = localtime + ".wav" rec.save(theFile) #wavePlot(theFile) messagebox.showinfo("Notification", "Your recording has been saved.") B2 = App.getNewButton("Rename", 1, 1) B5 = App.getNewButton("Back", 3, 0) B6 = App.getNewButton("Play", 0, 1) B7 = App.getNewButton("Delete", 2, 1) B11 = App.getNewButton("Analyse", 3, 1) B2['command'] = lambda: Rename(B2, B5, B6, B7, B11) B5['command'] = lambda: switchButton(B1, B2, B5, B6, B7, B3, B8, B11) B7['command'] = lambda: [ switchButton(B1, B2, B5, B6, B7, B3, B8, B11), delete(theFile) ] B6['command'] = lambda: play_audio(theFile) B11['command'] = lambda: goToAnalyse(B1, B3, B8, B2, B5, B6, B7, B11) #wavePlot(theFile) else: rec.stop() appearHome(B1, B3, B8)
def play_audio(self, start, length): """ Plays audio file starting at 'start' for 'length' seconds """ if self.audio_file is not None: play.play_audio(self.audio_file.get_text(), start, length)
def hello(): play_audio('utils/chewie.mp3') return 'Hello world!'
def commit(): play_audio('utils/chewie.mp3') return 'You\'ve commited a new file!'