Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write CSV output in sequence instead of chunk #37

Open
bhavara23 opened this issue Dec 15, 2021 · 4 comments
Open

Write CSV output in sequence instead of chunk #37

bhavara23 opened this issue Dec 15, 2021 · 4 comments

Comments

@bhavara23
Copy link

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
Copy link
Contributor

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

@bhavara23
Copy link
Author

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
Copy link
Contributor

chausner-audeering commented Dec 15, 2021

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants