Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to get sample depth from Sound?

48 views
Skip to first unread message

Владимир Коваль

unread,
Jan 15, 2022, 10:55:50 AM1/15/22
to Parselmouth
Hi!

I do:

snd = parselmouth.Sound(wav_path)

How can I get sample depth from snd (8 bit, 16, 24, etc. or 1-2-3 bytes)?

For now I use:
with wave.open(wav_path, 'rb') as file:
    sample_width = file.getsampwidth()
but if it possible only with parselmouth library - it will be great!

yannick...@gmail.com

unread,
Jan 15, 2022, 11:01:54 AM1/15/22
to Parselmouth
Hello!

Parselmouth abstracts this away, when reading (just like Praat itself, as Parselmouth mainly provides the Python interface). All audio files get read and immediately converted to 64-bit floating point numbers between -1 and 1.

If you need to know this information about the actual raw audio file, I think that your approach of using the built-in wave library seems correct. However, if the rest of your acoustic/phonetic/... analysis is done with Parselmouth, this info shouldn't matter too much?

Kind regards
Yannick

Владимир Коваль

unread,
Jan 15, 2022, 4:08:36 PM1/15/22
to Parselmouth
Got you, thanks!

Indeed, this is not a problem, just some perfectionism stuff :)

суббота, 15 января 2022 г. в 19:01:54 UTC+3, yannick...@gmail.com:

yannick...@gmail.com

unread,
Jan 15, 2022, 5:09:45 PM1/15/22
to Parselmouth
Ah, yes, I perfectly understand :-)

So, yes, I would guess Praat doesn't include such information because it wants to provide functionality on a higher level.
But then this is exactly why I wanted to develop Parselmouth, as it allows to combine with other Python libraries ;-)
Reply all
Reply to author
Forward
0 new messages