Beispiel #1
0
 def setUp(self):
     EnvironmentUtil.setup_fresh_test_env()
     self.context = CommandContext.via({'type': 'memory-db'})
     self.downCommand = DownCommand(self.context)
     self.newCommand = NewCommand(self.context)
     self.upCommand = UpCommand(self.context)
     self.checkCommand = CheckCommand(self.context)
Beispiel #2
0
 def setUp(self):
     EnvironmentUtil.setup_fresh_test_env()
     self.context = CommandContext.via({
       'type': 'memory-db'})
     self.downCommand = DownCommand(self.context)
     self.newCommand = NewCommand(self.context)
     self.upCommand  = UpCommand(self.context)
     self.checkCommand  = CheckCommand(self.context)
Beispiel #3
0
class CheckTest(unittest.TestCase):

    def setUp(self):
        EnvironmentUtil.setup_fresh_test_env()
        self.context = CommandContext.via({
          'type': 'memory-db'})
        self.downCommand = DownCommand(self.context)
        self.newCommand = NewCommand(self.context)
        self.upCommand  = UpCommand(self.context)
        self.checkCommand  = CheckCommand(self.context)

    def tearDown(self):
        EnvironmentUtil.teardown_fresh_test_env()

    def test_valid_chain(self):
        AlterUtil.create_alters([1, 2])
        AlterUtil.run_alters()
        sys.argv = make_argv([])
        self.checkCommand.run()

    def help_test_missing_alter(self, search, error):
        AlterUtil.create_alters([1])
        AlterUtil.run_alters()

        alter_files = ChainUtil.get_alter_files()
        self.assertEqual(len(alter_files), 2) # up and down
        os.remove([i for i in alter_files if search in i].pop())

        try:
            sys.argv = make_argv([])
            self.checkCommand.run()
        except error:
            pass

    def test_missing_up_alter(self):
        return self.help_test_missing_alter('-up', MissingUpAlterError)

    def test_missing_down_alter(self):
        return self.help_test_missing_alter('-down', MissingDownAlterError)
Beispiel #4
0
class CheckTest(unittest.TestCase):
    def setUp(self):
        EnvironmentUtil.setup_fresh_test_env()
        self.context = CommandContext.via({'type': 'memory-db'})
        self.downCommand = DownCommand(self.context)
        self.newCommand = NewCommand(self.context)
        self.upCommand = UpCommand(self.context)
        self.checkCommand = CheckCommand(self.context)

    def tearDown(self):
        EnvironmentUtil.teardown_fresh_test_env()

    def test_valid_chain(self):
        AlterUtil.create_alters([1, 2])
        AlterUtil.run_alters()
        sys.argv = make_argv([])
        self.checkCommand.run()

    def help_test_missing_alter(self, search, error):
        AlterUtil.create_alters([1])
        AlterUtil.run_alters()

        alter_files = ChainUtil.get_alter_files()
        self.assertEqual(len(alter_files), 2)  # up and down
        os.remove([i for i in alter_files if search in i].pop())

        try:
            sys.argv = make_argv([])
            self.checkCommand.run()
        except error:
            pass

    def test_missing_up_alter(self):
        return self.help_test_missing_alter('-up', MissingUpAlterError)

    def test_missing_down_alter(self):
        return self.help_test_missing_alter('-down', MissingDownAlterError)
Beispiel #5
0
#-*- coding:utf-8 -*-

from command import CheckCommand
from speech import MakeAudio, SpeechToText
from os import remove
from os.path import isfile
from keyboard import read_hotkey

if __name__ == "__main__":
    print("음성인식을 하려면 Ctrl+Shift 를 눌러주세요.")
    while True:
        try:
            rk = read_hotkey(suppress=False)
            if rk == 'ctrl+shift':

                print("10초간 인식합니다~")
                MakeAudio()
                print("10초간 인식 완료~")

                text = SpeechToText()
                CheckCommand(Text=text)

        except:
            print("에러 발생~")
            break

        finally:
            if isfile('sirius_cmd.wav'):
                remove('sirius_cmd.wav')