Exemplo n.º 1
0
    def __init__(self, *pubs, storage='local'):
        self.recorder = Recorder(storage=storage)

        if len(pubs) == 0:
            self.src = news_publishers.src

        else:
            self.src = {
                k: v
                for k, v in news_publishers.src.items() if k in pubs
            }
Exemplo n.º 2
0
    def prepare_basic_settings(self):
        self.recorder = Recorder()

        self.global_seed = utils.hash_seed(self.config.problem,
                                           self.config.seed)

        self.start = config.start
        self.end = config.start + config.n_sample
        self.current_idx = self.start
        self.current_stage = 0

        self.scene_reload_time = 10
Exemplo n.º 3
0
    def __init__(self, root):
        super().__init__()
        self.master = root
        self.log_directory_text = StringVar()
        self.log_directory_text.set("please select log directory ->")
        self.record_button_text = StringVar()
        self.record_button_text.set("Start Recording")
        self.record_count_text = StringVar()
        self.record_count_text.set("0 records")

        self.recorder = Recorder()
        self.init_ui()
        self.is_recording = False
Exemplo n.º 4
0
    def __init__(self, parent=None):
        super(MyWidget, self).__init__(parent)
        self.setupUi(self)
        self.setWindowTitle("VoiceReminder")
        self.pushButton.setStyleSheet("QPushButton{border-image: url(img/start.png)}")
        self.lcdNumber.setDigitCount(2)
        self.lcdNumber.setVisible(False)

        self.setting_time_dialog = SettingTimeDialog()
        self.setting_time_dialog.setWindowModality(Qt.ApplicationModal)
        self.record = Recorder()
        self.timer = QTimer()
        self.timing_thread = TimingThread()
        self.play_thread = PlayAudioThread()
        self.is_recording = False   # 用于判断当前是否正在录音

        self.display_all_reminders_list_from_existed_database()
        self.timer.timeout.connect(self.displaying_recording_time)
        self.pushButton.clicked.connect(lambda: self.start_or_stop_recording(self.is_recording))
        self.setting_time_dialog.pushButton.clicked.connect(self.set_time_from_dialog)
        self.listWidget.itemClicked.connect(self.play_corresponding_audio_file)  # itemClicked自带一个参数:item
        self.item_delete_signal.connect(self.display_all_reminders_list_from_existed_database)
        self.timing_thread.time_out_signal.connect(self.display_all_reminders_list_from_existed_database)
Exemplo n.º 5
0
                        action='store_true',
                        help='show list of audio devices and exit')
    parser.add_argument('-d',
                        '--device',
                        type=int,
                        default=DEVICE,
                        help='numeric id of input deviec')

    args = parser.parse_args()
    list_devices = args.list_devices
    device = args.device

    if list_devices:
        print(sd.query_devices())
    else:
        recorder = Recorder(device)
        raw_input('Press Enter to start recording')
        record_file = recorder.record()
        print('Recording...')
        raw_input('Press Enter to stop recording')
        recorder.stop()
        print('Recording finished.')
        transcriber = TranscribeClient()
        results = transcriber.transcribe(record_file)

        print('Transcript: {}'.format(results[0]))

        type(results)

        record_file = record_file.strip("'")
        os.remove(record_file)
Exemplo n.º 6
0
 def __init__(self):
     self.isRecording = False
     self.p = pyaudio
     self.rec = Recorder(channels=1)
     self.filename = ''
     self.t = TweetThis(filename=self.filename)
Exemplo n.º 7
0
#!/usr/bin/env python

import RPi.GPIO as GPIO
from record import Recorder
from control import Control
from command import Command
import time
import logging

GPIO_PIN = 3

recorder = Recorder()
control = Control()
logger = None


def main():
    button_press()
    return
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(GPIO_PIN, GPIO.IN)
    while True:
        button_state = GPIO.input(GPIO_PIN)
        #print button_state
        if button_state == 0:
            button_press()


def button_press():
    time.sleep(1)
    button_state = GPIO.input(GPIO_PIN)
Exemplo n.º 8
0
 def __init__(self, file_name):
     self._file_name = file_name
     self._recorder = Recorder(self._file_name)
     self._reporter = Reporter(self._recorder)
Exemplo n.º 9
0
def test_recorder_raises_illegal_record_error():
    recorder = Recorder("test_file")
    with pytest.raises(IllegalRecordError):
        csv_row = ["132332", "/a/b/c", "PUT1", 10]
        recorder._create_record(csv_row)
Exemplo n.º 10
0
def test_recorder_raises_nofile_exception():
    recorder = Recorder("test_file")
    with pytest.raises(FileDoesNotExistError):
        recorder._read_csv()
Exemplo n.º 11
0
def test_recorder_creates_record_from_csv():
    recorder = Recorder("test_file")
    csv_row = ["132332", "/a/b/c", "PUT", 10]
    assert len(recorder._records) == 0
    recorder._create_record(csv_row)
    assert len(recorder._records) == 1
Exemplo n.º 12
0
    def run(self):

        # 清除缓存
        files = os.listdir(self.cacheDir)
        for fname in files:
            if fname == "evaled":
                continue
            cachedFile = self.cacheDir + fname
            if self.deleteEvaled:
                os.remove(cachedFile)
            else:
                if (os.path.exists(self.evaledDir + fname)):
                    os.remove(self.evaledDir + fname)
                shutil.move(cachedFile, self.evaledDir)

        print("服务已部署,等待连接中")
        handler = easyconn.connectAcpt(self.port)
        recoder = Recorder(self.cacheDir)
        recoder.start()
        self.running = True
        print("连接已建立,正在提供分类服务")

        while (self.terminated is False):

            files = os.listdir(self.cacheDir)
            for fname in files:  # 清空整个文件夹

                # 获得一个预测
                if fname == 'evaled':  # 忽略evaled子目录
                    continue
                inputFile = self.cacheDir + fname
                y = None
                try:  # 预测
                    y = ac.evaluate.eval_file(model, inputFile)
                except ValueError:
                    print(f"音频{fname}读取失败")
                except FileNotFoundError:
                    print(f"音频{fname}读取失败")

                if y is not None:
                    jstr = toJson(y, os.path.getctime(inputFile))
                    try:
                        handler.send_data(jstr)
                    except ConnectionAbortedError:
                        self.terminated = True
                        break
                    print(f"自{fname}预测: {jstr}")
                if self.deleteEvaled and os.path.exists(inputFile):
                    os.remove(inputFile)
                else:
                    if (os.path.exists(self.evaledDir + fname)):
                        os.remove(self.evaledDir + fname)
                    shutil.move(inputFile, self.evaledDir)

            if len(files) <= 1:  # 目录空,等待
                time.sleep(0.1)

        #  结束
        recoder.terminated = True
        recoder.join()
        self.running = False
        handler.con.close()
        del handler
        print("服务终止")
Exemplo n.º 13
0
 def __init__(self):
     self.isPlaying = True
     self.p = pyaudio
     self.rec = Recorder(channels=1)
     self.play = None
     self.playback_thread = threading.Thread(name='button_listener', target=self.button_listener)
Exemplo n.º 14
0
    def on_click_play(self):
        # Check if number of trials
        if self.trial_no.text().isdigit():
            repeditions = int(self.trial_no.text())
        else:
            repeditions = 1

        if not self.soundfiles:
            mb = QMessageBox()
            mb.setLayout
            questionstart = mb.information(
                self, "Information",
                "No sound files location selected. Please Open sounds' location first.",
                QMessageBox.No | QMessageBox.Yes, QMessageBox.Yes)
            pass
        else:
            counter = 1
            mb = QMessageBox()
            mb.setLayout
            questionstart = mb.information(self, "Information",
                                           "<font size = 10 >Ready?</font>",
                                           QMessageBox.No | QMessageBox.Yes,
                                           QMessageBox.Yes)

            if questionstart == mb.Yes:
                while counter <= repeditions:
                    if self.randomize.isChecked():
                        file_list_order = self.soundfiles
                        file_list_order = random.sample(
                            file_list_order, len(file_list_order))
                    else:
                        file_list_order = self.soundfiles

                    for s in file_list_order:
                        try:
                            if system() == "Windows":
                                os.system("start " + s)
                                time.sleep(.900)
                            else:
                                os.system("play " + s)
                                rec = Recorder()
                        except KeyboardInterrupt:
                            break
                        currentDT = datetime.datetime.now()
                        if self.speaker_name.text() == "":
                            recordedfile = 'sound-' + \
                                str(counter) + "-" + \
                                str(currentDT.strftime(
                                    "%Y-%m-%d-%H_%M")) + '.wav'
                        else:
                            recordedfile = self.speaker_name.text() + '-repedition-' + \
                                str(counter) + "-" + \
                                str(currentDT.strftime(
                                    "%Y-%m-%d-%H_%M")) + '.wav'
                            trial1record = QMessageBox.question(
                                self, "Repedition " + str(counter),
                                "Repedition " + str(counter) +
                                "\nRecording... Press Yes to move to the next sound. Press No to quit.",
                                QMessageBox.No | QMessageBox.Yes,
                                QMessageBox.Yes)
                        with rec.open(recordedfile, 'wb') as recfile:
                            recfile.start_recording()
                            if trial1record == QMessageBox.Yes:
                                recfile.stop_recording()
                            else:
                                recfile.stop_recording()
                                break
                    counter += 1

                QMessageBox.information(self, "Good job!", "Very good!")
            else:
                pass
Exemplo n.º 15
0
                    help="Time interval between each data point in seconds")
parser.add_argument("--directory", "--dir", "-f", type=str, default="",
                    help="Directory to save log files")
parser.add_argument("--server", "--ip", type=str,
                    default="roborio-4774-frc.local", help="ip of the roborio")
parser.add_argument("--camera", "--cam", "-c", action="append", type=str,
                    help="ip of camera server")

args = parser.parse_args()

if args.camera is None:
    args.camera = ["http://10.47.74.36:1181/stream.mjpg",
                   "http://10.47.74.36:1182/stream.mjpg"]  # [0,1] testing

current_time = time.strftime("%H-%M-%S %d-%m-%y")
streams = [Recorder(args.directory + "cam" + str(num) + "-" + current_time +
                    ".mp4", stream, int(max(args.refresh_rate, 1)))
           for num, stream in enumerate(args.camera, start=1)]

logger = Log(4774)

if __name__ == "__main__":
    while True:
        start = time.monotonic()

        for stream in streams:
            stream.record()

        logger.log()

        elapsed = time.monotonic() - start
        if 1/args.refresh_rate - elapsed > 0:
Exemplo n.º 16
0
 def run(self):
     self.rec = Recorder()
     self.rec.start()