1
0
Преглед на файлове

Write start time of audio recording to csv file

miguel_bengala преди 1 година
родител
ревизия
ede8eb4e18
променени са 3 файла, в които са добавени 9 реда и са изтрити 2 реда
  1. 4 1
      controllers/microphones.ipynb
  2. 3 0
      controllers/microphones.py
  3. 2 1
      profiles/default.json

+ 4 - 1
controllers/microphones.ipynb

@@ -30,7 +30,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": 1,
    "metadata": {},
    "outputs": [
     {
@@ -96,7 +96,10 @@
     "                        # start stream if not active yet\n",
     "                        if not stream.active:\n",
     "                            print(\"Audio input stream started.\")\n",
+    "                            t0 = time.time()\n",
     "                            stream.start()\n",
+    "                            with open(cfg['csv_path'], 'a') as f:\n",
+    "                                f.write(\",\".join([str(x) for x in (t0,)]) + \"\\n\")\n",
     "\n",
     "                        f.write(MicrophoneController.queue.get())\n",
     "\n",

+ 3 - 0
controllers/microphones.py

@@ -51,7 +51,10 @@ class MicrophoneController(FPSTimes):
                         # start stream if not active yet
                         if not stream.active:
                             print("Audio input stream started.")
+                            t0 = time.time()
                             stream.start()
+                            with open(cfg['csv_path'], 'a') as f:
+                                f.write(",".join([str(x) for x in (t0,)]) + "\n")
 
                         f.write(MicrophoneController.queue.get())
 

+ 2 - 1
profiles/default.json

@@ -19,7 +19,8 @@
         "device": 58,
         "number_channels": 4,
         "channel_selectors": [8,9,10,11],
-        "file_path": "audio.mat5"
+        "file_path": "audio.mat5",
+        "csv_path": "microphones.csv"
     },
     "position": {
         "single_agent": true,