tools/utilities/pythonlibs/audio/view_audio.py
def start_playing(self, filename):
        """ Play a wav file, and classify the audio. Note we use a background thread to read the
        wav file and we setup a UI animation function to draw the sliding spectrogram image, this way
        the UI update doesn't interfere with the smoothness of the audio playback """
        if self.speaker is None:
            self.speaker = speaker.Speaker()
    
        self.stop()
        self.reading_input = False
        self.wav_file = wav_reader.WavReader(self.sample_rate, self.channels)
        self.wav_file.open(filename, self.featurizer.input_size, self.speaker)

        def update_func(frame_index):
            self.process_output()
            if not self.reading_input:
                self.after(1, self.on_stopped)
            self.set_spectrogram_image()
            return (self.spectrogram_image,)

        if self.animation:
            self.animation.event_source.stop()
        self.reading_input = True       

        # Start animation timer for updating the UI (e.g. spectrogram image) (30 fps is usually fine) 
        self.animation = animation.FuncAnimation(self.features_figure, update_func, interval=33, blit=True) 

        # start background thread to read and classify the audio.
        self.featurizer.open(self.wav_file)
        self.read_input_thread = Thread(target=self.on_read_features, args=())
        self.read_input_thread.daemon = True
        self.read_input_thread.start()
 Play a wav file, and classify the audio. Note we use a background thread to read the
        wav file and we setup a UI animation function to draw the sliding spectrogram image, this way
        the UI update doesn't interfere with the smoothness of the audio playback 
Play a wav file, and classify the audio. Note we use a background thread to read the
wav file and we setup a UI animation function to draw the sliding spectrogram image, this way
the UI update doesn't interfere with the smoothness of the audio playback
Play a wav file and classify the audio . Note we use a background thread to read the wav file and we setup a UI animation function to draw the sliding spectrogram image this way the UI update doesn ' t interfere with the smoothness of the audio playback
def start_playing(self, filename):
        if self.speaker is None:
            self.speaker = speaker.Speaker()
        self.stop()
        self.reading_input = False
        self.wav_file = wav_reader.WavReader(self.sample_rate, self.channels)
        self.wav_file.open(filename, self.featurizer.input_size, self.speaker)
        def update_func(frame_index):
            self.process_output()
            if not self.reading_input:
                self.after(1, self.on_stopped)
            self.set_spectrogram_image()
            return (self.spectrogram_image,)
        if self.animation:
            self.animation.event_source.stop()
        self.reading_input = True       
        self.animation = animation.FuncAnimation(self.features_figure, update_func, interval=33, blit=True) 
        self.featurizer.open(self.wav_file)
        self.read_input_thread = Thread(target=self.on_read_features, args=())
        self.read_input_thread.daemon = True
        self.read_input_thread.start()
def start_playing ( self , filename ) : if self . speaker is None : self . speaker = speaker . Speaker ( ) self . stop ( ) self . reading_input = False self . wav_file = wav_reader . WavReader ( self . sample_rate , self . channels ) self . wav_file . open ( filename , self . featurizer . input_size , self . speaker ) def update_func ( frame_index ) : self . process_output ( ) if not self . reading_input : self . after ( 1 , self . on_stopped ) self . set_spectrogram_image ( ) return ( self . spectrogram_image , ) if self . animation : self . animation . event_source . stop ( ) self . reading_input = True self . animation = animation . FuncAnimation ( self . features_figure , update_func , interval = 33 , blit = True ) self . featurizer . open ( self . wav_file ) self . read_input_thread = Thread ( target = self . on_read_features , args = ( ) ) self . read_input_thread . daemon = True self . read_input_thread . start ( )
Play a wav file, and classify the audio.
Play a wav file and classify the audio .
""" Play a wav file, and classify the audio. Note we use a background thread to read the
        wav file and we setup a UI animation function to draw the sliding spectrogram image, this way
        the UI update doesn't interfere with the smoothness of the audio playback """ # Start animation timer for updating the UI (e.g. spectrogram image) (30 fps is usually fine)  # start background thread to read and classify the audio.
self
filename