Exemplo n.º 1
0
    def __init__(self, audio_manager: AudioManager,
                 execution_manager: ExecutionManager,
                 trained_model_manager: TrainedModelManager):
        self.audio_manager = audio_manager
        self.execution_manager = execution_manager
        self.trained_model_manager = trained_model_manager
        super().__init__(rows=20, cols=1)
        self.add_entry(Label(text='Trained Models',
                             font_size='20sp',
                             color=[0, 0, 0, 1]),
                       position=(18, 0),
                       shape=(2, 1))

        self.trained_models_scroll = ScrollView()
        self.add_entry(self.trained_models_scroll,
                       position=(11, 0),
                       shape=(7, 1),
                       padding_x=(0.1, 0.1),
                       color=(0.6, 0.6, 0.6, 1))

        self.trained_models_widget = GridLayout(cols=1,
                                                spacing=2,
                                                size_hint_y=None)
        self.trained_models_scroll.add_widget(self.trained_models_widget)
        self.trained_models_widget.bind(
            minimum_height=self.trained_models_widget.setter('height'))

        EventListener.add_listener("update_trained_models",
                                   self.update_trained_model_entries)

        self.editor_controls = SparseGridLayout(rows=1, cols=4)
        self.add_entry(self.editor_controls,
                       position=(10, 0),
                       shape=(1, 1),
                       padding_x=(0.1, 0.1))

        self.close_button = Button(text="Close")
        self.close_button.on_press = self.close_trained_model
        self.editor_controls.add_entry(self.close_button,
                                       position=(0, 3),
                                       shape=(1, 1),
                                       padding_x=(0.01, 0.01),
                                       padding_y=(0.1, 0.1))
        self.editor_controls.hide_entry(self.close_button)

        self.result_viewer = TrainingResultView(self.audio_manager,
                                                self.execution_manager,
                                                self.trained_model_manager)
        self.add_entry(self.result_viewer, position=(0, 0), shape=(10, 1))
        self.hide_entry(self.result_viewer)

        self.update_trained_model_entries()
Exemplo n.º 2
0
    def __init__(self, audio_manager, model_manager, training_manager, execution_manager):
        self.audio_manager = audio_manager
        self.model_manager = model_manager
        self.training_manager = training_manager
        self.execution_manager = execution_manager
        super().__init__(rows=20, cols=1)
        self.add_entry(Label(text='Training', font_size='20sp', color=[0, 0, 0, 1]), position=(18, 0), shape=(2, 1))

        self.training_scroll = ScrollView()
        self.add_entry(self.training_scroll, position=(11, 0), shape=(7, 1), padding_x=(0.1, 0.1), color=(0.6, 0.6, 0.6, 1))

        self.training_widget = GridLayout(cols=1, spacing=2, size_hint_y=None)
        self.training_scroll.add_widget(self.training_widget)
        self.training_widget.bind(minimum_height=self.training_widget.setter('height'))

        self.editor_controls = SparseGridLayout(rows=1, cols=3)
        self.add_entry(self.editor_controls, position=(10, 0), shape=(1, 1), padding_x=(0.1, 0.1))

        self.new_button = Button(text="New")
        self.new_button.on_press = self.new_training
        self.editor_controls.add_entry(self.new_button, position=(0, 0), shape=(1, 1), padding_x=(0.01, 0.01), padding_y=(0.1, 0.1))

        self.save_button = Button(text="Save")
        self.save_button.on_press = self.save_training
        self.editor_controls.add_entry(self.save_button, position=(0, 1), shape=(1, 1), padding_x=(0.01, 0.01), padding_y=(0.1, 0.1))
        self.editor_controls.hide_entry(self.save_button)

        self.close_button = Button(text="Close")
        self.close_button.on_press = self.close_training
        self.editor_controls.add_entry(self.close_button, position=(0, 2), shape=(1, 1), padding_x=(0.01, 0.01), padding_y=(0.1, 0.1))
        self.editor_controls.hide_entry(self.close_button)

        self.training_editor = TrainingEditorView(self.model_manager, self.training_manager, self.execution_manager)
        EventListener.add_listener("refresh_training_view", self.update_training_definitions)
        self.add_entry(self.training_editor, position=(0, 0), shape=(10, 1))
        self.hide_entry(self.training_editor)

        self.update_training_definitions()
Exemplo n.º 3
0
 def delete_model(self):
     self.model_manager.delete_model(self.model_id)
     self.parent.remove_widget(self)
     self.delete_callback(self.model_id)
     EventListener.trigger_event("refresh_training_models")
Exemplo n.º 4
0
 def update_definition(self):
     self.training_manager.update_training(self.active_training,
                                           self.training_definition)
     self.update_start_button()
     EventListener.trigger_event("refresh_training_view")
Exemplo n.º 5
0
    def __init__(self, model_manager: ModelManager,
                 training_manager: TrainingManager,
                 execution_manager: ExecutionManager):
        self.model_manager = model_manager
        self.training_manager = training_manager
        self.execution_manager = execution_manager
        self.active_training = None
        self.training_definition = None

        super().__init__(rows=6, cols=2)

        self.background = Label()
        self.add_entry(self.background,
                       position=(0, 0),
                       shape=(6, 2),
                       padding_x=(0.01, 0.01),
                       padding_y=(0, 0.01),
                       color=(0.3, 0.3, 0.3, 1))

        self.add_entry(Label(text='Training Editor',
                             font_size='15sp',
                             color=[1, 1, 1, 1],
                             bold=True),
                       position=(5, 0),
                       shape=(1, 2))

        self.add_entry(Label(text="Model ID:",
                             font_size='15sp',
                             color=[0., 0., 0., 1.]),
                       position=(4, 0),
                       shape=(1, 1))
        self.models_button = Button(text='Choose model',
                                    size_hint=(None, None))
        self.models_dropdown = DropDown(auto_width=False)
        self.models_options = GridLayout(cols=1,
                                         spacing=0,
                                         size_hint_y=None,
                                         width=100)
        self.models_options.bind(
            minimum_height=self.models_options.setter('height'))
        self.models_scroll = ScrollView(size_hint_y=None, height=100)
        with self.models_scroll.canvas.before:
            Color(1, 1, 1, 1)
            Rectangle(pos=self.models_scroll.pos, size=self.models_scroll.size)
        self.models_scroll.add_widget(self.models_options)
        self.models_dropdown.add_widget(self.models_scroll)
        self.models_button.bind(on_release=self.models_dropdown.open)
        self.add_entry(self.models_button,
                       position=(4, 1),
                       shape=(1, 1),
                       padding_x=(0, 0.1),
                       padding_y=(0.03, 0.03))

        self.add_entry(Label(text="Learning Rate:",
                             font_size='15sp',
                             color=[0., 0., 0., 1.]),
                       position=(3, 0),
                       shape=(1, 1))
        self.learning_rate = TextInput(text="", multiline=False)
        self.learning_rate.bind(focus=self.update_learning_rate)
        self.add_entry(self.learning_rate,
                       position=(3, 1),
                       shape=(1, 1),
                       padding_x=(0, 0.1),
                       padding_y=(0.03, 0.03))

        self.add_entry(Label(text="Test Split:",
                             font_size='15sp',
                             color=[0., 0., 0., 1.]),
                       position=(2, 0),
                       shape=(1, 1))
        self.test_split = TextInput(text="", multiline=False)
        self.test_split.bind(focus=self.update_test_split)
        self.add_entry(self.test_split,
                       position=(2, 1),
                       shape=(1, 1),
                       padding_x=(0, 0.1),
                       padding_y=(0.03, 0.03))

        self.add_entry(Label(text="Iterations:",
                             font_size='15sp',
                             color=[0., 0., 0., 1.]),
                       position=(1, 0),
                       shape=(1, 1))
        self.iterations = TextInput(text="", multiline=False)
        self.iterations.bind(focus=self.update_iterations)
        self.add_entry(self.iterations,
                       position=(1, 1),
                       shape=(1, 1),
                       padding_x=(0, 0.1),
                       padding_y=(0.03, 0.03))

        self.start_training_button = Button(text="Start Training")
        self.start_training_button.bind(on_press=self.start_training)
        self.add_entry(self.start_training_button,
                       position=(0, 0.6),
                       shape=(1, 1),
                       padding_x=(0, 0.1),
                       padding_y=(0.03, 0.03))

        EventListener.add_listener("refresh_training_models",
                                   self.update_model_entries)

        self.float_regex = re.compile(r"^\d+(.\d+)?$")
        self.int_regex = re.compile(r"^\d+$")

        self.update_model_entries()
Exemplo n.º 6
0
 def save_model(self):
     self.model_manager.save_model(self.model_editor.active_model)
     EventListener.trigger_event("refresh_training_models")
     self.update_model_definitions()
Exemplo n.º 7
0
 def check_hide_save(self, model_id):
     if model_id == self.model_editor.active_model:
         EventListener.trigger_event("refresh_training_models")
         self.editor_controls.hide_entry(self.save_button)
Exemplo n.º 8
0
 def update_model(self):
     self.model_manager.update_model(self.active_model,
                                     self.model_definition)
     EventListener.trigger_event("refresh_model_definitions")
Exemplo n.º 9
0
 def delete_clip(self):
     self.audio_manager.delete_audio(self.audio_id)
     self.parent.remove_widget(self)
     EventListener.trigger_event("update_audio_entries")
Exemplo n.º 10
0
    def __init__(self, audio_manager: AudioManager,
                 execution_manager: ExecutionManager,
                 trained_model_manager: TrainedModelManager):
        self.audio_manager = audio_manager
        self.execution_manager = execution_manager
        self.trained_model_manager = trained_model_manager
        self.active_trained_model_id = None
        self.trained_model = None
        self.train_stats = None

        super().__init__(rows=6, cols=2)

        self.background = Label()
        self.add_entry(self.background,
                       position=(0, 0),
                       shape=(6, 2),
                       padding_x=(0.01, 0.01),
                       padding_y=(0, 0.01),
                       color=(0.3, 0.3, 0.3, 1))

        self.add_entry(Label(text='Model Results',
                             font_size='15sp',
                             color=[1, 1, 1, 1],
                             bold=True),
                       position=(5, 0),
                       shape=(1, 2))

        self.add_entry(Label(text="Model ID:",
                             font_size='15sp',
                             color=[0., 0., 0., 1.]),
                       position=(4, 0),
                       shape=(1, 1))
        self.model_id = Label(text="",
                              font_size='15sp',
                              color=[0., 0., 0., 1.])
        self.add_entry(self.model_id, position=(4, 1), shape=(1, 1))

        self.add_entry(Label(text="Training ID:",
                             font_size='15sp',
                             color=[0., 0., 0., 1.]),
                       position=(3, 0),
                       shape=(1, 1))
        self.training_id = Label(text="",
                                 font_size='15sp',
                                 color=[0., 0., 0., 1.])
        self.add_entry(self.training_id, position=(3, 1), shape=(1, 1))

        self.add_entry(Label(text="Iterations: ",
                             font_size='15sp',
                             color=[0., 0., 0., 1.]),
                       position=(2, 0),
                       shape=(1, 1))
        self.iterations = Label(text="",
                                font_size='15sp',
                                color=[0., 0., 0., 1.])
        self.add_entry(self.iterations, position=(2, 1), shape=(1, 1))

        self.add_entry(Label(text="Accuracy: ",
                             font_size='15sp',
                             color=[0., 0., 0., 1.]),
                       position=(1, 0),
                       shape=(1, 1))
        self.accuracy = Label(text="",
                              font_size='15sp',
                              color=[0., 0., 0., 1.])
        self.add_entry(self.accuracy, position=(1, 1), shape=(1, 1))

        self.start_training_button = Button(text="Test Audio")
        self.start_training_button.bind(on_press=self.test_model_against_audio)
        self.add_entry(self.start_training_button,
                       position=(0, 0.4),
                       shape=(1, 0.8),
                       padding_x=(0, 0.1),
                       padding_y=(0.03, 0.03))

        self.audio_button = Button(text='Choose audio', size_hint=(None, None))
        self.audio_dropdown = DropDown(auto_width=False)
        self.audio_options = GridLayout(cols=1,
                                        spacing=0,
                                        size_hint_y=None,
                                        width=100)
        self.audio_options.bind(
            minimum_height=self.audio_options.setter('height'))
        self.audio_scroll = ScrollView(size_hint_y=None, height=100)
        with self.audio_scroll.canvas.before:
            Color(1, 1, 1, 1)
            Rectangle(pos=self.audio_scroll.pos, size=self.audio_scroll.size)
        self.audio_scroll.add_widget(self.audio_options)
        self.audio_dropdown.add_widget(self.audio_scroll)
        self.audio_button.bind(on_release=self.audio_dropdown.open)
        self.add_entry(self.audio_button,
                       position=(0, 1),
                       shape=(1, 0.8),
                       padding_x=(0, 0.1),
                       padding_y=(0.03, 0.03))
        self.selected_audio_id = None

        self.update_audio_entries()
        EventListener.add_listener("update_audio_entries",
                                   self.update_audio_entries)
Exemplo n.º 11
0
 def stop_record_callback(self):
     self.record_button.on_press = self.record_callback
     self.record_button.text = "Record"
     self.audio_manager.stop_recording()
     self.update_recording_entries()
     EventListener.trigger_event("update_audio_entries")