audeering / opensmile

The Munich Open-Source Large-Scale Multimedia Feature Extractor
https://audeering.github.io/opensmile/
Other
553 stars 74 forks source link

Write CSV output in sequence instead of chunk #37

Open bhavara23 opened 2 years ago

bhavara23 commented 2 years ago

When I tried to read the last line data from CSV in real-time while running opensmile command, I am unable to fetch every individual data but it skips a chunk of data.

I am assuming that the data is been written as a chunk instead of a single row at a time in CSV. If this is the case then, is there a way I can save the data one by one in sequence instead of dumping it as a chunk into the CSV?

chausner-audeering commented 2 years ago

Yes, by enabling the flush option of cCsvSink: https://audeering.github.io/opensmile/_components/cCsvSink.html

bhavara23 commented 2 years ago

I am trying to read the live data that is going into a CSV through a python script. Now, I have added flush = 1in the config. Now I want to read the last line of that CSV but it is still missing a few lines when I am trying to print the data.

Here is the code example:

textfile = "csv/test2_prosody.csv"

prev = '0'
while True:
    count = 0
    with open(textfile, 'r') as f:
        last_line = f.readlines()[-2]
        if prev != last_line
               print(last_line)
        prev = last_line

Output:


529;5.300000;0;0;0

530;5.310000;0;0;0

532;5.330000;0;0;0

533;5.340000;0;0;0

534;5.350000;0;0;0

In the Output you can see that, there is data missing between the 2nd and 3rd rows. It's random, sometimes there will be 1 data missing and sometimes there will be "n" data missing.

chausner-audeering commented 2 years ago

If flush is enabled, the data should get written to the CSV as soon as it is generated. If you say, some results are missing, that would mean that openSMILE has not computed them yet. Either, because more input is required or because the results are still being computed and not available yet.

In general, though, if you want to process results live from openSMILE, SMILEapi in combination with cExternalSink is a much cleaner and reliable approach than doing it through a CSV file. See https://audeering.github.io/opensmile/reference.html#smileapi-c-api-and-wrappers and also https://github.com/audeering/opensmile-python.

bhavara23 commented 2 years ago

can you help me with how to configure cExternalSink and get live results with respect to prosody, egemaps and mfcc?