Reading a CSV File and converting it to Pitch and Duration Tier using Python

33 views
Skip to first unread message

Suraj Jaiswal

unread,
Dec 9, 2021, 4:31:55 AM12/9/21
to Parselmouth
Hello!

I have a CSV file containing 2 columns Time_s and F0_Hz I want to read this file in python and then convert it to pitch and duration tier so that I can change the scale.

I am using this method: - 

table=call("Read Table from comma-separated file", path)
table_real_tier = call(table, "To RealTier")
table_pitch_tier=call(table_real_tier, "To PitchTier")
call(table_pitch_tier, "Multiply frequencies", sound.xmin, sound.xmax, factor)
call([table_pitch_tier, manipulation], "Replace pitch tier")
call(manipulation, "Get resynthesis (overlap-add)")

But I am getting the error in 2nd line itself i.e. "Command "To RealTier" not available for given objects."

So, can anyone help me with this?

Thanks!


yannick...@gmail.com

unread,
Dec 11, 2021, 3:22:28 PM12/11/21
to Parselmouth
Hi!

The issue, I believe, is that you didn't add any arguments in this call. Parselmouth automatically adds "..." to the end of an action name if you pass at least one argument. So, if you'd write `call(table, "To RealTier...")`, I believe you should get another error, and similarly if you'd call `call(table, "To RealTier", "Time_s", "F0_Hz", 0, float('nan'))`.

Does this work? If not, please do follow up and I'll give it a closer look!

Apart from that, I'll just point out that since this is Python, you could of course also read in the CSV with e.g. Pandas and create and fill the RealTier/PitchTier from there. In the case you've shown here, that would probably just make things more complex, but it is possible :-)

Kind regards
Yannick
Reply all
Reply to author
Forward
0 new messages