tools/utilities/pythonlibs/audio/view_audio.py
def start_recording(self):
        """ Start recording audio from the microphone nd classify the audio. Note we use a background thread to 
        process the audio 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 microphone readings """ 

        self.stop()

        input_channel = None

        if self.serial_port:
            import serial_reader
            self.serial = serial_reader.SerialReader(0.001)
            self.serial.open(self.featurizer.input_size, self.serial_port)
            input_channel = self.serial
        else:
            if self.microphone is None:
                self.microphone = microphone.Microphone(False)
    
            num_channels = 1
            self.microphone.open(self.featurizer.input_size, self.sample_rate, num_channels, self.input_device)        
            input_channel = self.microphone
        
        def update_func(frame_index):
            # this is an animation callback to update the UI every 33 milliseconds.
            self.process_output()
            self.set_spectrogram_image()
            if not self.reading_input:
                self.after(1, self.on_stopped)
            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 recorded audio.
        self.featurizer.open(input_channel)
        self.read_input_thread = Thread(target=self.on_read_features, args=())
        self.read_input_thread.daemon = True
        self.read_input_thread.start()
 Start recording audio from the microphone nd classify the audio. Note we use a background thread to 
        process the audio 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 microphone readings 
Start recording audio from the microphone nd classify the audio. Note we use a background thread to
process the audio 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 microphone readings
Start recording audio from the microphone nd classify the audio . Note we use a background thread to process the audio 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 microphone readings
def start_recording(self):
        self.stop()
        input_channel = None
        if self.serial_port:
            import serial_reader
            self.serial = serial_reader.SerialReader(0.001)
            self.serial.open(self.featurizer.input_size, self.serial_port)
            input_channel = self.serial
        else:
            if self.microphone is None:
                self.microphone = microphone.Microphone(False)
            num_channels = 1
            self.microphone.open(self.featurizer.input_size, self.sample_rate, num_channels, self.input_device)        
            input_channel = self.microphone
        def update_func(frame_index):
            self.process_output()
            self.set_spectrogram_image()
            if not self.reading_input:
                self.after(1, self.on_stopped)
            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(input_channel)
        self.read_input_thread = Thread(target=self.on_read_features, args=())
        self.read_input_thread.daemon = True
        self.read_input_thread.start()
def start_recording ( self ) : self . stop ( ) input_channel = None if self . serial_port : import serial_reader self . serial = serial_reader . SerialReader ( 0.001 ) self . serial . open ( self . featurizer . input_size , self . serial_port ) input_channel = self . serial else : if self . microphone is None : self . microphone = microphone . Microphone ( False ) num_channels = 1 self . microphone . open ( self . featurizer . input_size , self . sample_rate , num_channels , self . input_device ) input_channel = self . microphone def update_func ( frame_index ) : self . process_output ( ) self . set_spectrogram_image ( ) if not self . reading_input : self . after ( 1 , self . on_stopped ) 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 ( input_channel ) self . read_input_thread = Thread ( target = self . on_read_features , args = ( ) ) self . read_input_thread . daemon = True self . read_input_thread . start ( )
Start recording audio from the microphone nd classify the audio.
Start recording audio from the microphone nd classify the audio .
""" Start recording audio from the microphone nd classify the audio. Note we use a background thread to 
        process the audio 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 microphone readings """ # this is an animation callback to update the UI every 33 milliseconds. # Start animation timer for updating the UI (e.g. spectrogram image) (30 fps is usually fine)  # start background thread to read and classify the recorded audio.
self