Scientist @ Fraunhofer IDMT

Liketohear-Ai

Last updated: February 19th, 20202020-02-19Project preview
In [1]:
import pandas as pd
import json
import re
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
In [2]:
def get_decibels(msg):
    if "RMS level in dB" in msg:
        decibels_str_list=re.findall("\\[[^\\]]*]",msg)[0][1:-1].split()
        decibels={str(k+1):float(v) for (k,v) in enumerate(decibels_str_list)}
        decibels["sum"]=sum(decibels.values())
    else:
        print("unknown message: "+str(msg))
        decibels={}
    return decibels
    
def parse_file(file):
    with open(file) as f:
        j=json.load(f)
        
    measures=[]
    cur_presetx=0
    cur_presety=0
    cur_el={}
    for el in j:
        if "data" in el:
            if "presetx" in el["data"] and "presety" in el["data"]:
                cur_el["presetx"]=el["data"]["presetx"]
                cur_el["presety"]=el["data"]["presety"]
                measures+=[cur_el]    
            else: #intensity data
                decibels=get_decibels(el["msg"])
                el.update(decibels)
                cur_el=el
    return pd.DataFrame(measures)
In [8]:
df=pd.DataFrame(parse_file("liketohear_soundwalk_loggings/Results_2019-10-16/user_interface_2_nn04im02.log"))

df["date"]=pd.to_datetime(df["date"])
df.head()
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-8-1479aaea0316> in <module>
----> 1 df=pd.DataFrame(parse_file("liketohear_soundwalk_loggings/Results_2019-10-16/user_interface_2_nn04im02.log"))
      2 
      3 df["date"]=pd.to_datetime(df["date"])
      4 df.head()

<ipython-input-2-074d52fc559b> in parse_file(file)
     10 
     11 def parse_file(file):
---> 12     with open(file) as f:
     13         j=json.load(f)
     14 

FileNotFoundError: [Errno 2] No such file or directory: 'liketohear_soundwalk_loggings/Results_2019-10-16/user_interface_2_nn04im02.log'
In [9]:
df=pd.DataFrame(parse_file("/home/peggy/2019_HHYL2H/liketohear Loggings/user_interface_2_nn04im02.log"))

df["date"]=pd.to_datetime(df["date"])
df.head()
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-9-eb967bd3f271> in <module>
----> 1 df=pd.DataFrame(parse_file("/home/peggy/2019_HHYL2H/liketohear Loggings/user_interface_2_nn04im02.log"))
      2 
      3 df["date"]=pd.to_datetime(df["date"])
      4 df.head()

<ipython-input-2-074d52fc559b> in parse_file(file)
     10 
     11 def parse_file(file):
---> 12     with open(file) as f:
     13         j=json.load(f)
     14 

FileNotFoundError: [Errno 2] No such file or directory: '/home/peggy/2019_HHYL2H/liketohear Loggings/user_interface_2_nn04im02.log'
In [5]:
df=pd.DataFrame(parse_file("/home/peggy/2019_HHYL2H/liketohear Loggings/Results_2019-10-16_8p//user_interface_2_nn04im02.log"))

df["date"]=pd.to_datetime(df["date"])
df.head()
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-5-22675b830762> in <module>
----> 1 df=pd.DataFrame(parse_file("/home/peggy/2019_HHYL2H/liketohear Loggings/Results_2019-10-16_8p//user_interface_2_nn04im02.log"))
      2 
      3 df["date"]=pd.to_datetime(df["date"])
      4 df.head()

<ipython-input-2-074d52fc559b> in parse_file(file)
     10 
     11 def parse_file(file):
---> 12     with open(file) as f:
     13         j=json.load(f)
     14 

FileNotFoundError: [Errno 2] No such file or directory: '/home/peggy/2019_HHYL2H/liketohear Loggings/Results_2019-10-16_8p//user_interface_2_nn04im02.log'
In [11]:
df=pd.DataFrame(parse_file(user_interface_2_nn04im02.log"))

df["date"]=pd.to_datetime(df["date"])
df.head()
  File "<ipython-input-11-3b08900428cf>", line 1
    df=pd.DataFrame(parse_file(user_interface_5_wenig_KENAEN06.log"))
                                                                     ^
SyntaxError: EOL while scanning string literal
In [ ]:
 
Notebooks AI
Notebooks AI Profile20060